Commit 4fd96650 by Nicolas Capens

Use original PowerVR ColourGrading ES 3.0 sample.

Change-Id: Ifff92974ea41be61244ae1c09e2d54e299c10eeb Reviewed-on: https://swiftshader-review.googlesource.com/4160Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent cc6fe659
...@@ -240,12 +240,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{B7E24D8E ...@@ -240,12 +240,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{B7E24D8E
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGL", "OpenGL\libGL\libGL.vcxproj", "{3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libGL", "OpenGL\libGL\libGL.vcxproj", "{3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES2ColourGrading", "..\tests\third_party\PowerVR\Examples\Intermediate\ColourGrading\OGLES2\Build\WindowsVC2010\OGLES2ColourGrading.vcxproj", "{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}"
ProjectSection(ProjectDependencies) = postProject
{B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78}
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6} = {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLSimpleCube", "..\tests\OGLSimpleCube\OGLSimpleCube.vcxproj", "{27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLSimpleCube", "..\tests\OGLSimpleCube\OGLSimpleCube.vcxproj", "{27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67} = {3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67} {3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67} = {3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}
...@@ -253,6 +247,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLSimpleCube", "..\tests\O ...@@ -253,6 +247,14 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLSimpleCube", "..\tests\O
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D3D9", "D3D9\D3D9.vcxproj", "{F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D3D9", "D3D9\D3D9.vcxproj", "{F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES3ColourGrading", "..\tests\third_party\PowerVR\Examples\Intermediate\ColourGrading\OGLES3\Build\WindowsVC2010\OGLES3ColourGrading.vcxproj", "{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}"
ProjectSection(ProjectDependencies) = postProject
{B5871A7A-968C-42E3-A33B-981E6F448E78} = {B5871A7A-968C-42E3-A33B-981E6F448E78}
{E746FCA9-64C3-433E-85E8-9A5A67AB7ED6} = {E746FCA9-64C3-433E-85E8-9A5A67AB7ED6}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES3Tools", "..\tests\third_party\PowerVR\Tools\OGLES3\Build\WindowsVC2010\OGLES3Tools.vcxproj", "{9088FC9E-9843-4E0D-85D0-1B657AFC480A}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
...@@ -671,18 +673,6 @@ Global ...@@ -671,18 +673,6 @@ Global
{3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}.Release|Win32.Build.0 = Release|Win32 {3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}.Release|Win32.Build.0 = Release|Win32
{3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}.Release|x64.ActiveCfg = Release|x64 {3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}.Release|x64.ActiveCfg = Release|x64
{3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}.Release|x64.Build.0 = Release|x64 {3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67}.Release|x64.Build.0 = Release|x64
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Debug|Win32.ActiveCfg = Debug|Win32
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Debug|Win32.Build.0 = Debug|Win32
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Debug|x64.ActiveCfg = Debug|x64
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Debug|x64.Build.0 = Debug|x64
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Profile|Win32.ActiveCfg = Release|Win32
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Profile|Win32.Build.0 = Release|Win32
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Profile|x64.ActiveCfg = Release|x64
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Profile|x64.Build.0 = Release|x64
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Release|Win32.ActiveCfg = Release|Win32
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Release|Win32.Build.0 = Release|Win32
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Release|x64.ActiveCfg = Release|x64
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}.Release|x64.Build.0 = Release|x64
{27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}.Debug|Win32.ActiveCfg = Debug|Win32 {27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}.Debug|Win32.ActiveCfg = Debug|Win32
{27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}.Debug|Win32.Build.0 = Debug|Win32 {27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}.Debug|Win32.Build.0 = Debug|Win32
{27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}.Debug|x64.ActiveCfg = Debug|x64 {27E15292-4A8D-4BA0-8D9B-5D1ECFF85747}.Debug|x64.ActiveCfg = Debug|x64
...@@ -707,6 +697,30 @@ Global ...@@ -707,6 +697,30 @@ Global
{F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}.Release|Win32.Build.0 = Release|Win32 {F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}.Release|Win32.Build.0 = Release|Win32
{F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}.Release|x64.ActiveCfg = Release|x64 {F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}.Release|x64.ActiveCfg = Release|x64
{F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}.Release|x64.Build.0 = Release|x64 {F18D5ABF-CA3A-4B74-BDB2-4A1957C86F18}.Release|x64.Build.0 = Release|x64
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Debug|Win32.ActiveCfg = Debug|Win32
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Debug|Win32.Build.0 = Debug|Win32
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Debug|x64.ActiveCfg = Debug|x64
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Debug|x64.Build.0 = Debug|x64
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Profile|Win32.ActiveCfg = Release|Win32
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Profile|Win32.Build.0 = Release|Win32
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Profile|x64.ActiveCfg = Release|x64
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Profile|x64.Build.0 = Release|x64
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Release|Win32.ActiveCfg = Release|Win32
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Release|Win32.Build.0 = Release|Win32
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Release|x64.ActiveCfg = Release|x64
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}.Release|x64.Build.0 = Release|x64
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Debug|Win32.ActiveCfg = Debug|Win32
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Debug|Win32.Build.0 = Debug|Win32
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Debug|x64.ActiveCfg = Debug|x64
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Debug|x64.Build.0 = Debug|x64
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Profile|Win32.ActiveCfg = Release|Win32
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Profile|Win32.Build.0 = Release|Win32
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Profile|x64.ActiveCfg = Release|x64
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Profile|x64.Build.0 = Release|x64
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Release|Win32.ActiveCfg = Release|Win32
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Release|Win32.Build.0 = Release|Win32
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Release|x64.ActiveCfg = Release|x64
{9088FC9E-9843-4E0D-85D0-1B657AFC480A}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -745,7 +759,8 @@ Global ...@@ -745,7 +759,8 @@ Global
{AB1EB229-D86C-41B3-8E20-7A7E1FF5DDF5} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {AB1EB229-D86C-41B3-8E20-7A7E1FF5DDF5} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{B7E24D8E-6BE9-4DEF-A8B9-6A6E60CA60E9} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {B7E24D8E-6BE9-4DEF-A8B9-6A6E60CA60E9} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67} = {D33114D7-E582-4D61-B27D-FAB0297C43FF} {3EF851E7-4AAB-4C7C-9A79-3122CEA1EB67} = {D33114D7-E582-4D61-B27D-FAB0297C43FF}
{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{27E15292-4A8D-4BA0-8D9B-5D1ECFF85747} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D} {27E15292-4A8D-4BA0-8D9B-5D1ECFF85747} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2} = {ED25C308-5BDB-43A7-BED6-C2C059FC2D7D}
{9088FC9E-9843-4E0D-85D0-1B657AFC480A} = {B7E24D8E-6BE9-4DEF-A8B9-6A6E60CA60E9}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
uniform sampler2D sTexture;
varying mediump vec2 texCoords;
void main()
{
highp vec3 vCol = texture2D(sTexture, texCoords).rgb;
gl_FragColor = vec4(vCol, 1.0);
}
texld r0, v0.xy, s0
mov r1, r0
mov r2.xyz, v1.xyzx
mov r3.x, r1.x
mul r4.xyz, r2.xyz, r3.x
mov r5.x, v1.wx
mov r6.x, r1.wx
mul r7.x, r5.x, r6.x
mov r8, r4.xyz
mov r8.w, r7.x
mov oC0, r8
mov r9, r8
texld r0, v0.xy, s0
mov r1.xyz, r0.xyzx
mov r2.xyz, r1.xyz
texld r3, r2.xyz, s1
mov r4.xyz, r3.xyzx
mov r5.xyz, r4.xyz
mov r6, r5.xyz
mov r6.w, {1, 1, 1, 1}.x
mov oC0, r6
mov r7, r6
texld r0, v0.xy, s0
mov r1.xyz, r0.xyzx
mov r2.xyz, r1.xyz
mov r3, r2.xyz
mov r3.w, {1, 1, 1, 1}.x
mov oC0, r3
mov r4, r3
texld r0, v0.xy, s0
mov r1.xyz, r0.xyzx
mov r2.xyz, r1.xyz
mul r3.xyz, r2.xyz, v1.xyz
add r4.xyz, r3.xyz, v2.xyz
mov r5.xyz, r4.xyz
mov r6, r5.xyz
mov r6.w, {1, 1, 1, 1}.x
mov oC0, r6
mov r7, r6
attribute highp vec4 inVertex;
attribute mediump vec2 inTexCoord;
varying mediump vec2 texCoords;
void main()
{
gl_Position = inVertex;
texCoords = inTexCoord;
}
#version 300 es
uniform sampler2D sTexture;
in mediump vec2 texCoords;
layout(location = 0) out lowp vec4 oFragColour;
void main()
{
highp vec3 vCol = texture(sTexture, texCoords).rgb;
oFragColour = vec4(vCol, 1.0);
}
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2013 # Visual Studio 2010
VisualStudioVersion = 12.0.21005.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES3ColourGrading", "OGLES3ColourGrading.vcxproj", "{9DAFEE32-19F6-4410-AA09-2B564FB86F62}"
MinimumVisualStudioVersion = 10.0.40219.1 ProjectSection(ProjectDependencies) = postProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES2ColourGrading", "OGLES2ColourGrading.vcxproj", "{9DAFEE32-19F6-4410-AA09-2B564FB86F62}" {09ABE661-9BC0-4152-A820-1FB0522CAC01} = {09ABE661-9BC0-4152-A820-1FB0522CAC01}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES3Tools", "..\..\..\..\..\..\Tools\OGLES3\Build\WindowsVC2010\OGLES3Tools.vcxproj", "{09ABE661-9BC0-4152-A820-1FB0522CAC01}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
...@@ -21,6 +24,14 @@ Global ...@@ -21,6 +24,14 @@ Global
{9DAFEE32-19F6-4410-AA09-2B564FB86F62}.Release|Win32.Build.0 = Release|Win32 {9DAFEE32-19F6-4410-AA09-2B564FB86F62}.Release|Win32.Build.0 = Release|Win32
{9DAFEE32-19F6-4410-AA09-2B564FB86F62}.Release|x64.ActiveCfg = Release|x64 {9DAFEE32-19F6-4410-AA09-2B564FB86F62}.Release|x64.ActiveCfg = Release|x64
{9DAFEE32-19F6-4410-AA09-2B564FB86F62}.Release|x64.Build.0 = Release|x64 {9DAFEE32-19F6-4410-AA09-2B564FB86F62}.Release|x64.Build.0 = Release|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|Win32.ActiveCfg = Debug|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|Win32.Build.0 = Debug|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|x64.ActiveCfg = Debug|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|x64.Build.0 = Debug|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|Win32.ActiveCfg = Release|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|Win32.Build.0 = Release|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.ActiveCfg = Release|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{9F14A82C-19FD-4A8A-B4FF-FF00FFF6F2DD}</ProjectGuid> <ProjectGuid>{2EA5725B-25DA-44E2-B71E-BD9F55F3C2E2}</ProjectGuid>
<RootNamespace>OGLES2ColourGrading</RootNamespace> <RootNamespace>OGLES3ColourGrading</RootNamespace>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
...@@ -81,32 +81,32 @@ ...@@ -81,32 +81,32 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BUILD_OGLES2;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES2;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES3;</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_32\Lib;..\..\..\..\..\..\Tools\OGLES2\Build\WindowsVC2010\$(IntDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_32\Lib;..\..\..\..\..\..\Tools\OGLES3\Build\WindowsVC2010\$(IntDir)</AdditionalLibraryDirectories>
<AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES2Tools.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES3Tools.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BUILD_OGLES2;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES2;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES3;</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_64\Lib;..\..\..\..\..\..\Tools\OGLES2\Build\WindowsVC2010\$(IntDir);</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_64\Lib;..\..\..\..\..\..\Tools\OGLES3\Build\WindowsVC2010\$(IntDir);</AdditionalLibraryDirectories>
<AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES2Tools.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES3Tools.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
...@@ -115,8 +115,8 @@ ...@@ -115,8 +115,8 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BUILD_OGLES2;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES2;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES3;</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
...@@ -125,8 +125,8 @@ ...@@ -125,8 +125,8 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_32\Lib;..\..\..\..\..\..\Tools\OGLES2\Build\WindowsVC2010\$(IntDir);</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_32\Lib;..\..\..\..\..\..\Tools\OGLES3\Build\WindowsVC2010\$(IntDir);</AdditionalLibraryDirectories>
<AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES2Tools.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES3Tools.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
...@@ -135,8 +135,8 @@ ...@@ -135,8 +135,8 @@
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BUILD_OGLES2;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES2;</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\..\..\..\..\Shell;..\..\..\..\..\..\Shell\API\KEGL;..\..\..\..\..\..\Shell\OS\Windows;..\..\..\..\..\..\Builds\Include;..\..\..\..\..\..\Tools\OGLES2;..\..\..\..\..\..\Tools\OGLES3;</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
...@@ -145,12 +145,12 @@ ...@@ -145,12 +145,12 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_64\Lib;..\..\..\..\..\..\Tools\OGLES2\Build\WindowsVC2010\$(IntDir);</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>..\..\..\..\..\..\Builds\Windows\x86_64\Lib;..\..\..\..\..\..\Tools\OGLES3\Build\WindowsVC2010\$(IntDir);</AdditionalLibraryDirectories>
<AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES2Tools.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>libEGL.lib;libGLESv2.lib;OGLES3Tools.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\OGLES2ColourGrading.cpp" /> <ClCompile Include="..\..\OGLES3ColourGrading.cpp" />
<ClCompile Include="..\..\..\..\..\..\Shell\PVRShell.cpp" /> <ClCompile Include="..\..\..\..\..\..\Shell\PVRShell.cpp" />
<ClCompile Include="..\..\..\..\..\..\Shell\API\KEGL\PVRShellAPI.cpp" /> <ClCompile Include="..\..\..\..\..\..\Shell\API\KEGL\PVRShellAPI.cpp" />
<ClCompile Include="..\..\..\..\..\..\Shell\OS\Windows\PVRShellOS.cpp" /> <ClCompile Include="..\..\..\..\..\..\Shell\OS\Windows\PVRShellOS.cpp" />
...@@ -414,8 +414,8 @@ ...@@ -414,8 +414,8 @@
</CustomBuild> </CustomBuild>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\..\..\..\Tools\OGLES2\Build\WindowsVC2010\OGLES2Tools.vcxproj"> <ProjectReference Include="..\..\..\..\..\..\Tools\OGLES3\Build\WindowsVC2010\OGLES3Tools.vcxproj">
<Project>{09abe661-9bc0-4152-a820-1fb0522cac01}</Project> <Project>{9088fc9e-9843-4e0d-85d0-1b657afc480a}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\OGLES2ColourGrading.cpp"> <ClCompile Include="..\..\OGLES3ColourGrading.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\..\..\..\Shell\PVRShell.cpp"> <ClCompile Include="..\..\..\..\..\..\Shell\PVRShell.cpp">
......
...@@ -13,18 +13,21 @@ ...@@ -13,18 +13,21 @@
// File data // File data
static const char _BackgroundFragShader_fsh[] = static const char _BackgroundFragShader_fsh[] =
"uniform sampler2D sTexture;\n" "#version 300 es\n"
"\n" "\n"
"varying mediump vec2 texCoords;\n" "uniform sampler2D sTexture;\n"
"\n"
"in mediump vec2 texCoords;\n"
"layout(location = 0) out lowp vec4 oFragColour;\n"
"\n" "\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" highp vec3 vCol = texture2D(sTexture, texCoords).rgb;\n" " highp vec3 vCol = texture(sTexture, texCoords).rgb;\n"
" gl_FragColor = vec4(vCol, 1.0);\n" " oFragColour = vec4(vCol, 1.0);\n"
"}\n"; "}\n";
// Register BackgroundFragShader.fsh in memory file system at application startup time // Register BackgroundFragShader.fsh in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_BackgroundFragShader_fsh("BackgroundFragShader.fsh", _BackgroundFragShader_fsh, 172); static CPVRTMemoryFileSystem RegisterFile_BackgroundFragShader_fsh("BackgroundFragShader.fsh", _BackgroundFragShader_fsh, 235);
// ******** End: BackgroundFragShader.fsh ******** // ******** End: BackgroundFragShader.fsh ********
...@@ -13,20 +13,23 @@ ...@@ -13,20 +13,23 @@
// File data // File data
static const char _FragShader_fsh[] = static const char _FragShader_fsh[] =
"#version 300 es\n"
"\n"
"uniform sampler2D sTexture;\n" "uniform sampler2D sTexture;\n"
"uniform mediump sampler3D\t\tsColourLUT;\n" "uniform mediump sampler3D\t\tsColourLUT;\n"
"\n" "\n"
"varying mediump vec2 texCoords;\n" "in mediump vec2 texCoords;\n"
"layout(location = 0) out lowp vec4 oFragColour;\n"
"\n" "\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" highp vec3 vCol = texture2D(sTexture, texCoords).rgb;\n" " highp vec3 vCol = texture(sTexture, texCoords).rgb;\n"
"\tlowp vec3 vAlteredCol = texture3D(sColourLUT, vCol).rgb;\n" "\tlowp vec3 vAlteredCol = texture(sColourLUT, vCol.rgb).rgb;\n"
" gl_FragColor = vec4(vAlteredCol, 1.0);\n" " oFragColour = vec4(vAlteredCol, 1.0);\n"
"}\n"; "}\n";
// Register FragShader.fsh in memory file system at application startup time // Register FragShader.fsh in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_FragShader_fsh("FragShader.fsh", _FragShader_fsh, 282); static CPVRTMemoryFileSystem RegisterFile_FragShader_fsh("FragShader.fsh", _FragShader_fsh, 341);
// ******** End: FragShader.fsh ******** // ******** End: FragShader.fsh ********
...@@ -15,20 +15,20 @@ ...@@ -15,20 +15,20 @@
static const char _SceneFragShader_fsh[] = static const char _SceneFragShader_fsh[] =
"uniform sampler2D sTexture;\n" "uniform sampler2D sTexture;\n"
"\n" "\n"
"varying lowp vec3 DiffuseLight;\n" "varying lowp vec3 DiffuseLight;\n"
"varying lowp vec3 SpecularLight;\n" "varying lowp vec3 SpecularLight;\n"
"varying mediump vec2 TexCoord;\n" "varying mediump vec2 TexCoord;\n"
"\n" "\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
"\tlowp vec3 texColor = texture2D(sTexture, TexCoord).rgb;\n" "\tlowp vec3 texColor = texture2D(sTexture, TexCoord).rgb;\n"
"\tlowp vec3 color = (texColor * DiffuseLight) + SpecularLight;\n" "\tlowp vec3 color = (texColor * DiffuseLight) + SpecularLight;\n"
"\tgl_FragColor = vec4(color, 1.0);\n" "\tgl_FragColor = vec4(color, 1.0);\n"
"}\n" "}\n"
"\n"; "\n";
// Register SceneFragShader.fsh in memory file system at application startup time // Register SceneFragShader.fsh in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_SceneFragShader_fsh("SceneFragShader.fsh", _SceneFragShader_fsh, 302); static CPVRTMemoryFileSystem RegisterFile_SceneFragShader_fsh("SceneFragShader.fsh", _SceneFragShader_fsh, 306);
// ******** End: SceneFragShader.fsh ******** // ******** End: SceneFragShader.fsh ********
...@@ -13,18 +13,18 @@ ...@@ -13,18 +13,18 @@
// File data // File data
static const char _SceneVertShader_vsh[] = static const char _SceneVertShader_vsh[] =
"attribute highp vec4 inVertex;\n" "attribute highp vec4 inVertex;\n"
"attribute highp vec3 inNormal;\n" "attribute highp vec3 inNormal;\n"
"attribute highp vec2 inTexCoord;\n" "attribute highp vec2 inTexCoord;\n"
"\n" "\n"
"uniform highp mat4 MVPMatrix;\n" "uniform highp mat4 MVPMatrix;\n"
"uniform highp vec3 LightDirection;\n" "uniform highp vec3 LightDirection;\n"
"uniform highp float MaterialBias;\n" "uniform highp float MaterialBias;\n"
"uniform highp float MaterialScale;\n" "uniform highp float MaterialScale;\n"
"\n" "\n"
"varying lowp vec3 DiffuseLight;\n" "varying lowp vec3 DiffuseLight;\n"
"varying lowp vec3 SpecularLight;\n" "varying lowp vec3 SpecularLight;\n"
"varying mediump vec2 TexCoord;\n" "varying mediump vec2 TexCoord;\n"
"\n" "\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
......
...@@ -13,19 +13,24 @@ ...@@ -13,19 +13,24 @@
// File data // File data
static const char _VertShader_vsh[] = static const char _VertShader_vsh[] =
"attribute highp vec4 inVertex;\n" "#version 300 es\n"
"attribute mediump vec2 inTexCoord;\n"
"\n" "\n"
"varying mediump vec2 texCoords;\n" "#define VERTEX_ARRAY 0\n"
"#define TEXCOORD_ARRAY 1\n"
"\n"
"layout (location = VERTEX_ARRAY) in highp vec4 inVertex;\n"
"layout (location = TEXCOORD_ARRAY) in mediump vec2 inTexCoord;\n"
"\n"
"out mediump vec2 texCoords;\n"
"\t\t\n" "\t\t\n"
"void main() \n" "void main() \n"
"{ \n" "{ \n"
"\tgl_Position = inVertex;\n" "\tgl_Position = inVertex;\n"
"\ttexCoords = inTexCoord;\n" "\ttexCoords = inTexCoord;\n"
"} \n"; "} \n";
// Register VertShader.vsh in memory file system at application startup time // Register VertShader.vsh in memory file system at application startup time
static CPVRTMemoryFileSystem RegisterFile_VertShader_vsh("VertShader.vsh", _VertShader_vsh, 177); static CPVRTMemoryFileSystem RegisterFile_VertShader_vsh("VertShader.vsh", _VertShader_vsh, 301);
// ******** End: VertShader.vsh ******** // ******** End: VertShader.vsh ********
#version 300 es
uniform sampler2D sTexture; uniform sampler2D sTexture;
uniform mediump sampler3D sColourLUT; uniform mediump sampler3D sColourLUT;
varying mediump vec2 texCoords; in mediump vec2 texCoords;
layout(location = 0) out lowp vec4 oFragColour;
void main() void main()
{ {
highp vec3 vCol = texture2D(sTexture, texCoords).rgb; highp vec3 vCol = texture(sTexture, texCoords).rgb;
lowp vec3 vAlteredCol = texture3D(sColourLUT, vCol).rgb; lowp vec3 vAlteredCol = texture(sColourLUT, vCol.rgb).rgb;
gl_FragColor = vec4(vAlteredCol, 1.0); oFragColour = vec4(vAlteredCol, 1.0);
} }
/****************************************************************************** /******************************************************************************
@File OGLES2ColourGrading.cpp @File OGLES3ColourGrading.cpp
@Title Colour grading @Title Colour grading
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
******************************************************************************/ ******************************************************************************/
#include "PVRShell.h" #include "PVRShell.h"
#include "OGLES2Tools.h" #include "OGLES3Tools.h"
/****************************************************************************** /******************************************************************************
Constants Constants
...@@ -88,15 +88,8 @@ const char* const c_pszLUTNames[] = ...@@ -88,15 +88,8 @@ const char* const c_pszLUTNames[] =
/*!**************************************************************************** /*!****************************************************************************
Class implementing the PVRShell functions. Class implementing the PVRShell functions.
******************************************************************************/ ******************************************************************************/
class OGLES2ColourGrading : public PVRShell class OGLES3ColourGrading : public PVRShell
{ {
enum EMultisampleExtension
{
eMultisampleExtension_None,
eMultisampleExtension_IMG,
eMultisampleExtension_ANGLE
};
// Print3D object // Print3D object
CPVRTPrint3D m_Print3D; CPVRTPrint3D m_Print3D;
...@@ -158,7 +151,6 @@ class OGLES2ColourGrading : public PVRShell ...@@ -158,7 +151,6 @@ class OGLES2ColourGrading : public PVRShell
// Texture IDs used by the app // Texture IDs used by the app
GLuint m_uiTextureToRenderTo; GLuint m_uiTextureToRenderTo;
GLuint m_uiDepthToRenderTo;
// Handle for our FBO and the depth buffer that it requires // Handle for our FBO and the depth buffer that it requires
GLuint m_uiFBO; GLuint m_uiFBO;
...@@ -171,47 +163,7 @@ class OGLES2ColourGrading : public PVRShell ...@@ -171,47 +163,7 @@ class OGLES2ColourGrading : public PVRShell
// Start time // Start time
unsigned long m_ulStartTime; unsigned long m_ulStartTime;
// Extensions
CPVRTgles2Ext m_Extensions;
// Discard the frame buffer attachments
bool m_bDiscard;
bool m_bMultisampledSupported;
EMultisampleExtension m_eMultisampleMode;
bool m_flipX;
bool m_flipY;
public: public:
OGLES2ColourGrading() :
m_uiMaskTexture(0),
m_uiBackgroundTexture(0),
m_iCurrentLUT(0),
m_ui32FullScreenRectVBO(0),
m_ui32VertexStride(0),
m_puiMaskVBO(0),
m_puiMaskIBO(0),
m_ui32BackgroundVBO(0),
m_uiPostVertShader(0),
m_uiPostFragShader(0),
m_uiBackgroundFragShader(0),
m_uiSceneVertShader(0),
m_uiSceneFragShader(0),
m_i32OriginalFbo(0),
m_uiTextureToRenderTo(0),
m_uiDepthToRenderTo(0),
m_uiFBO(0),
m_uiFBOMultisampled(0),
m_uiDepthBufferMultisampled(0),
m_uiColourBufferMultisampled(0),
m_ulStartTime(0),
m_bDiscard(false),
m_bMultisampledSupported(false),
m_flipX(false),
m_flipY(false)
{
}
// PVRShell functions // PVRShell functions
virtual bool InitApplication(); virtual bool InitApplication();
virtual bool InitView(); virtual bool InitView();
...@@ -237,7 +189,7 @@ private: ...@@ -237,7 +189,7 @@ private:
If the rendering context is lost, InitApplication() will If the rendering context is lost, InitApplication() will
not be called again. not be called again.
******************************************************************************/ ******************************************************************************/
bool OGLES2ColourGrading::InitApplication() bool OGLES3ColourGrading::InitApplication()
{ {
// Get and set the read path for content files // Get and set the read path for content files
CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath)); CPVRTResourceFile::SetReadPath((char*)PVRShellGet(prefReadPath));
...@@ -268,7 +220,7 @@ bool OGLES2ColourGrading::InitApplication() ...@@ -268,7 +220,7 @@ bool OGLES2ColourGrading::InitApplication()
If the rendering context is lost, QuitApplication() will If the rendering context is lost, QuitApplication() will
not be called. not be called.
******************************************************************************/ ******************************************************************************/
bool OGLES2ColourGrading::QuitApplication() bool OGLES3ColourGrading::QuitApplication()
{ {
// Free the memory allocated for the scene // Free the memory allocated for the scene
m_Mask.Destroy(); m_Mask.Destroy();
...@@ -288,7 +240,7 @@ bool OGLES2ColourGrading::QuitApplication() ...@@ -288,7 +240,7 @@ bool OGLES2ColourGrading::QuitApplication()
@Description Loads and parses the bundled PFX and generates the various @Description Loads and parses the bundled PFX and generates the various
effect objects. effect objects.
******************************************************************************/ ******************************************************************************/
bool OGLES2ColourGrading::LoadShaders(CPVRTString& ErrorStr) bool OGLES3ColourGrading::LoadShaders(CPVRTString& ErrorStr)
{ {
// Load and compile the shaders from files. // Load and compile the shaders from files.
if(PVRTShaderLoadFromFile(NULL, c_szVertShaderSrcFile, GL_VERTEX_SHADER, GL_SGX_BINARY_IMG, &m_uiPostVertShader, &ErrorStr) != PVR_SUCCESS) if(PVRTShaderLoadFromFile(NULL, c_szVertShaderSrcFile, GL_VERTEX_SHADER, GL_SGX_BINARY_IMG, &m_uiPostVertShader, &ErrorStr) != PVR_SUCCESS)
...@@ -373,7 +325,7 @@ bool OGLES2ColourGrading::LoadShaders(CPVRTString& ErrorStr) ...@@ -373,7 +325,7 @@ bool OGLES2ColourGrading::LoadShaders(CPVRTString& ErrorStr)
@Description Loads the mesh data required for this training course into @Description Loads the mesh data required for this training course into
vertex buffer objects vertex buffer objects
******************************************************************************/ ******************************************************************************/
void OGLES2ColourGrading::LoadVbos(const bool bRotated) void OGLES3ColourGrading::LoadVbos(const bool bRotated)
{ {
if(!m_puiMaskVBO) if(!m_puiMaskVBO)
m_puiMaskVBO = new GLuint[m_Mask.nNumMesh]; m_puiMaskVBO = new GLuint[m_Mask.nNumMesh];
...@@ -495,20 +447,13 @@ void OGLES2ColourGrading::LoadVbos(const bool bRotated) ...@@ -495,20 +447,13 @@ void OGLES2ColourGrading::LoadVbos(const bool bRotated)
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
bool OGLES2ColourGrading::CreateFBO() bool OGLES3ColourGrading::CreateFBO()
{ {
// Figure out if the platform supports either EXT or IMG extension
m_eMultisampleMode = eMultisampleExtension_IMG;
if(m_Extensions.glRenderbufferStorageMultisampleANGLE)
{
m_eMultisampleMode = eMultisampleExtension_ANGLE;
}
GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0 }; GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0 };
// Query the max amount of samples that are supported, we are going to use the max // Query the max amount of samples that are supported, we are going to use the max
GLint samples; GLint samples;
glGetIntegerv(GL_MAX_SAMPLES_EXT, &samples); glGetIntegerv(GL_MAX_SAMPLES, &samples);
// Get the currently bound frame buffer object. On most platforms this just gives 0. // Get the currently bound frame buffer object. On most platforms this just gives 0.
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_i32OriginalFbo); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &m_i32OriginalFbo);
...@@ -516,7 +461,7 @@ bool OGLES2ColourGrading::CreateFBO() ...@@ -516,7 +461,7 @@ bool OGLES2ColourGrading::CreateFBO()
// Create a texture for rendering to // Create a texture for rendering to
glGenTextures(1, &m_uiTextureToRenderTo); glGenTextures(1, &m_uiTextureToRenderTo);
glBindTexture(GL_TEXTURE_2D, m_uiTextureToRenderTo); glBindTexture(GL_TEXTURE_2D, m_uiTextureToRenderTo);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, PVRShellGet(prefWidth), PVRShellGet(prefHeight), 0, GL_RGB, GL_UNSIGNED_BYTE, 0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, PVRShellGet(prefWidth), PVRShellGet(prefHeight), 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
...@@ -525,18 +470,12 @@ bool OGLES2ColourGrading::CreateFBO() ...@@ -525,18 +470,12 @@ bool OGLES2ColourGrading::CreateFBO()
// Create the object that will allow us to render to the aforementioned texture // Create the object that will allow us to render to the aforementioned texture
glGenFramebuffers(1, &m_uiFBO); glGenFramebuffers(1, &m_uiFBO);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_uiFBO);
glDrawBuffers(1, drawBuffers);
glReadBuffer(GL_COLOR_ATTACHMENT0);
// Attach the texture to the FBO // Attach the texture to the FBO
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_uiTextureToRenderTo, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_uiTextureToRenderTo, 0);
if(!m_bMultisampledSupported)
{
glGenTextures(1, &m_uiDepthToRenderTo);
glBindTexture(GL_TEXTURE_2D, m_uiDepthToRenderTo);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, PVRShellGet(prefWidth), PVRShellGet(prefHeight), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_uiDepthToRenderTo, 0);
}
// Check that our FBO creation was successful // Check that our FBO creation was successful
GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); GLuint uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
...@@ -546,46 +485,38 @@ bool OGLES2ColourGrading::CreateFBO() ...@@ -546,46 +485,38 @@ bool OGLES2ColourGrading::CreateFBO()
return false; return false;
} }
// Generate and bind a render buffer which will become a multisampled depth buffer shared between our two FBOs // Create and initialize the multi-sampled FBO.
if(m_bMultisampledSupported)
{
// Create and initialize the multi-sampled FBO.
// Create the object that will allow us to render to the aforementioned texture
glGenFramebuffers(1, &m_uiFBOMultisampled);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFBOMultisampled);
glGenRenderbuffers(1, &m_uiDepthBufferMultisampled); // Create the object that will allow us to render to the aforementioned texture
glBindRenderbuffer(GL_RENDERBUFFER, m_uiDepthBufferMultisampled); glGenFramebuffers(1, &m_uiFBOMultisampled);
glBindFramebuffer(GL_FRAMEBUFFER, m_uiFBOMultisampled);
if(m_eMultisampleMode == eMultisampleExtension_ANGLE)
m_Extensions.glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, samples, GL_DEPTH_COMPONENT16, PVRShellGet(prefWidth), PVRShellGet(prefHeight)); glDrawBuffers(1, drawBuffers);
else glReadBuffer(GL_COLOR_ATTACHMENT0);
m_Extensions.glRenderbufferStorageMultisampleIMG(GL_RENDERBUFFER, samples, GL_DEPTH_COMPONENT16, PVRShellGet(prefWidth), PVRShellGet(prefHeight));
glGenRenderbuffers(1, &m_uiColourBufferMultisampled); // Generate and bind a render buffer which will become a multisampled depth buffer shared between our two FBOs
glBindRenderbuffer(GL_RENDERBUFFER, m_uiColourBufferMultisampled); glGenRenderbuffers(1, &m_uiDepthBufferMultisampled);
if(m_eMultisampleMode == eMultisampleExtension_ANGLE) glBindRenderbuffer(GL_RENDERBUFFER, m_uiDepthBufferMultisampled);
m_Extensions.glRenderbufferStorageMultisampleANGLE(GL_RENDERBUFFER, samples, GL_RGB8_OES, PVRShellGet(prefWidth), PVRShellGet(prefHeight)); glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_DEPTH_COMPONENT24, PVRShellGet(prefWidth), PVRShellGet(prefHeight));
else
m_Extensions.glRenderbufferStorageMultisampleIMG(GL_RENDERBUFFER, samples, GL_RGB8_OES, PVRShellGet(prefWidth), PVRShellGet(prefHeight));
glBindRenderbuffer(GL_RENDERBUFFER, 0); glGenRenderbuffers(1, &m_uiColourBufferMultisampled);
glBindRenderbuffer(GL_RENDERBUFFER, m_uiColourBufferMultisampled);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, GL_RGB8, PVRShellGet(prefWidth), PVRShellGet(prefHeight));
glBindRenderbuffer(GL_RENDERBUFFER, 0);
// Attach the multisampled depth buffer we created earlier to our FBO. // Attach the multisampled depth buffer we created earlier to our FBO.
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uiDepthBufferMultisampled); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uiDepthBufferMultisampled);
// Attach the multisampled colour renderbuffer to the FBO // Attach the multisampled colour renderbuffer to the FBO
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_uiColourBufferMultisampled); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_uiColourBufferMultisampled);
// Check that our FBO creation was successful // Check that our FBO creation was successful
uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER); uStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if(uStatus != GL_FRAMEBUFFER_COMPLETE) if(uStatus != GL_FRAMEBUFFER_COMPLETE)
{ {
PVRShellSet(prefExitMessage, "ERROR: Failed to initialise multisampled FBO"); PVRShellSet(prefExitMessage, "ERROR: Failed to initialise multisampled FBO");
return false; return false;
} }
}
// Unbind the frame buffer object so rendering returns back to the backbuffer // Unbind the frame buffer object so rendering returns back to the backbuffer
glBindFramebuffer(GL_FRAMEBUFFER, m_i32OriginalFbo); glBindFramebuffer(GL_FRAMEBUFFER, m_i32OriginalFbo);
...@@ -601,10 +532,8 @@ bool OGLES2ColourGrading::CreateFBO() ...@@ -601,10 +532,8 @@ bool OGLES2ColourGrading::CreateFBO()
Used to initialize variables that are dependent on the rendering Used to initialize variables that are dependent on the rendering
context (e.g. textures, vertex buffers, etc.) context (e.g. textures, vertex buffers, etc.)
******************************************************************************/ ******************************************************************************/
bool OGLES2ColourGrading::InitView() bool OGLES3ColourGrading::InitView()
{ {
m_Extensions.LoadExtensions();
// Initialize the textures used by Print3D. // Initialize the textures used by Print3D.
bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen); bool bRotate = PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen);
...@@ -636,12 +565,12 @@ bool OGLES2ColourGrading::InitView() ...@@ -636,12 +565,12 @@ bool OGLES2ColourGrading::InitView()
return false; return false;
} }
glTexParameteri(GL_TEXTURE_3D_OES, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D_OES, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D_OES, GL_TEXTURE_WRAP_R_OES, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_3D_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} }
// Load the effects // Load the effects
...@@ -652,12 +581,6 @@ bool OGLES2ColourGrading::InitView() ...@@ -652,12 +581,6 @@ bool OGLES2ColourGrading::InitView()
return false; return false;
} }
// Create a multisampled FBO if the required extension is supported
m_eMultisampleMode = eMultisampleExtension_None;
m_bMultisampledSupported = false;
m_bMultisampledSupported |= CPVRTgles2Ext::IsGLExtensionSupported("GL_ANGLE_framebuffer_multisample");
m_bMultisampledSupported |= CPVRTgles2Ext::IsGLExtensionSupported("GL_IMG_multisampled_render_to_texture");
// Create FBOs // Create FBOs
if(!CreateFBO()) if(!CreateFBO())
{ {
...@@ -665,13 +588,6 @@ bool OGLES2ColourGrading::InitView() ...@@ -665,13 +588,6 @@ bool OGLES2ColourGrading::InitView()
return false; return false;
} }
// Check to see if the GL_EXT_discard_framebuffer extension is supported
m_bDiscard = CPVRTgles2Ext::IsGLExtensionSupported("GL_EXT_discard_framebuffer");
if(m_bDiscard)
{
m_bDiscard = m_Extensions.glDiscardFramebufferEXT != 0;
}
// Initialise VBO data // Initialise VBO data
LoadVbos(bRotate); LoadVbos(bRotate);
...@@ -699,14 +615,13 @@ bool OGLES2ColourGrading::InitView() ...@@ -699,14 +615,13 @@ bool OGLES2ColourGrading::InitView()
@Description Code in ReleaseView() will be called by PVRShell when the @Description Code in ReleaseView() will be called by PVRShell when the
application quits or before a change in the rendering context. application quits or before a change in the rendering context.
******************************************************************************/ ******************************************************************************/
bool OGLES2ColourGrading::ReleaseView() bool OGLES3ColourGrading::ReleaseView()
{ {
// Frees the texture // Frees the texture
glDeleteTextures(1, &m_uiMaskTexture); glDeleteTextures(1, &m_uiMaskTexture);
glDeleteTextures(1, &m_uiBackgroundTexture); glDeleteTextures(1, &m_uiBackgroundTexture);
glDeleteTextures(eLast, m_uiLUTs); glDeleteTextures(eLast, m_uiLUTs);
glDeleteTextures(1, &m_uiTextureToRenderTo); glDeleteTextures(1, &m_uiTextureToRenderTo);
glDeleteTextures(1, &m_uiDepthToRenderTo);
// Release Vertex buffer object. // Release Vertex buffer object.
glDeleteBuffers(1, &m_ui32FullScreenRectVBO); glDeleteBuffers(1, &m_ui32FullScreenRectVBO);
...@@ -753,7 +668,7 @@ bool OGLES2ColourGrading::ReleaseView() ...@@ -753,7 +668,7 @@ bool OGLES2ColourGrading::ReleaseView()
Will also manage relevant OS events. The user has access to Will also manage relevant OS events. The user has access to
these events through an abstraction layer provided by PVRShell. these events through an abstraction layer provided by PVRShell.
******************************************************************************/ ******************************************************************************/
bool OGLES2ColourGrading::RenderScene() bool OGLES3ColourGrading::RenderScene()
{ {
// Clears the colour buffer // Clears the colour buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
...@@ -775,19 +690,11 @@ bool OGLES2ColourGrading::RenderScene() ...@@ -775,19 +690,11 @@ bool OGLES2ColourGrading::RenderScene()
if(m_iCurrentLUT < eA) if(m_iCurrentLUT < eA)
m_iCurrentLUT = eB; m_iCurrentLUT = eB;
} }
else if(PVRShellIsKeyPressed(PVRShellKeyNameUP))
{
m_flipX = !m_flipX;
}
else if(PVRShellIsKeyPressed(PVRShellKeyNameDOWN))
{
m_flipY = !m_flipY;
}
// Render to our texture // Render to our texture
{ {
// Bind our FBO // Bind our FBO
glBindFramebuffer(GL_FRAMEBUFFER, m_bMultisampledSupported ? m_uiFBOMultisampled : m_uiFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_uiFBOMultisampled);
// Clear the colour and depth buffer of our FBO surface // Clear the colour and depth buffer of our FBO surface
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
...@@ -848,73 +755,42 @@ bool OGLES2ColourGrading::RenderScene() ...@@ -848,73 +755,42 @@ bool OGLES2ColourGrading::RenderScene()
// Unbind the VBO // Unbind the VBO
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
if(m_bDiscard) // Was GL_EXT_discard_framebuffer supported? // Give the drivers a hint that we don't want the depth and stencil information stored for future use.
{ const GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
/* glInvalidateFramebuffer(GL_FRAMEBUFFER, 2, attachments);
Give the drivers a hint that we don't want the depth and stencil information stored for future use.
Note: This training course doesn't have any stencil information so the STENCIL_ATTACHMENT enum
is used for demonstrations purposes only and will be ignored by the driver.
*/
const GLenum attachments[] = { GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT };
m_Extensions.glDiscardFramebufferEXT(GL_FRAMEBUFFER, 2, attachments);
}
// Blit and resolve the multisampled render buffer to the non-multisampled FBO // Blit and resolve the multisampled render buffer to the non-multisampled FBO
if(m_bMultisampledSupported) glBindFramebuffer(GL_READ_FRAMEBUFFER, m_uiFBOMultisampled);
{ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_uiFBO);
glBindFramebuffer(GL_READ_FRAMEBUFFER_NV, m_uiFBOMultisampled); glBlitFramebuffer(0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight), 0, 0, PVRShellGet(prefWidth), PVRShellGet(prefHeight), GL_COLOR_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_NV, m_uiFBO);
int w = PVRShellGet(prefWidth);
int h = PVRShellGet(prefHeight);
int destX0 = m_flipX ? w : 0;
int destX1 = m_flipX ? 0 : w;
int destY0 = m_flipY ? h : 0;
int destY1 = m_flipY ? 0 : h;
m_Extensions.glBlitFramebufferNV(0, 0, w, h, destX0, destY0, destX1, destY1, GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
// We are done with rendering to our FBO so switch back to the back buffer. // We are done with rendering to our FBO so switch back to the back buffer.
glBindFramebuffer(GL_FRAMEBUFFER, m_i32OriginalFbo); glBindFramebuffer(GL_FRAMEBUFFER, m_i32OriginalFbo);
} }
GLenum error = glGetError();
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
error = glGetError();
// Use shader program // Use shader program
glUseProgram(m_PostShaderProgram.uiId); glUseProgram(m_PostShaderProgram.uiId);
// Bind the VBO // Bind the VBO
glBindBuffer(GL_ARRAY_BUFFER, m_ui32FullScreenRectVBO); glBindBuffer(GL_ARRAY_BUFFER, m_ui32FullScreenRectVBO);
error = glGetError();
// Enable the vertex attribute arrays // Enable the vertex attribute arrays
glEnableVertexAttribArray(VERTEX_ARRAY); glEnableVertexAttribArray(VERTEX_ARRAY);
glEnableVertexAttribArray(TEXCOORD_ARRAY); glEnableVertexAttribArray(TEXCOORD_ARRAY);
error = glGetError();
// Set the vertex attribute offsets // Set the vertex attribute offsets
glVertexAttribPointer(VERTEX_ARRAY, 4, GL_FLOAT, GL_FALSE, m_ui32VertexStride, 0); glVertexAttribPointer(VERTEX_ARRAY, 4, GL_FLOAT, GL_FALSE, m_ui32VertexStride, 0);
glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, m_ui32VertexStride, (void*) (4 * sizeof(GLfloat))); glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, m_ui32VertexStride, (void*) (4 * sizeof(GLfloat)));
error = glGetError();
// Bind texture // Bind texture
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_uiTextureToRenderTo); glBindTexture(GL_TEXTURE_2D, m_uiTextureToRenderTo);
error = glGetError();
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_3D_OES, m_uiLUTs[m_iCurrentLUT]); glBindTexture(GL_TEXTURE_3D, m_uiLUTs[m_iCurrentLUT]);
error = glGetError();
// Draw a screen-aligned quad. // Draw a screen-aligned quad.
...@@ -922,7 +798,7 @@ bool OGLES2ColourGrading::RenderScene() ...@@ -922,7 +798,7 @@ bool OGLES2ColourGrading::RenderScene()
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// Draw the right-hande side showing the scene how it looks without // Draw the right-hande side showing the scene how it looks without
glBindTexture(GL_TEXTURE_3D_OES, m_uiLUTs[eIdentity]); glBindTexture(GL_TEXTURE_3D, m_uiLUTs[eIdentity]);
glDrawArrays(GL_TRIANGLE_STRIP, 2, 4); glDrawArrays(GL_TRIANGLE_STRIP, 2, 4);
// Safely disable the vertex attribute arrays // Safely disable the vertex attribute arrays
...@@ -945,7 +821,7 @@ bool OGLES2ColourGrading::RenderScene() ...@@ -945,7 +821,7 @@ bool OGLES2ColourGrading::RenderScene()
@Description Draws a SPODMesh after the model view matrix has been set and @Description Draws a SPODMesh after the model view matrix has been set and
the material prepared. the material prepared.
******************************************************************************/ ******************************************************************************/
void OGLES2ColourGrading::DrawMesh(const int i32NodeIndex) void OGLES3ColourGrading::DrawMesh(const int i32NodeIndex)
{ {
int i32MeshIndex = m_Mask.pNode[i32NodeIndex].nIdx; int i32MeshIndex = m_Mask.pNode[i32NodeIndex].nIdx;
SPODMesh* pMesh = &m_Mask.pMesh[i32MeshIndex]; SPODMesh* pMesh = &m_Mask.pMesh[i32MeshIndex];
...@@ -986,10 +862,10 @@ void OGLES2ColourGrading::DrawMesh(const int i32NodeIndex) ...@@ -986,10 +862,10 @@ void OGLES2ColourGrading::DrawMesh(const int i32NodeIndex)
******************************************************************************/ ******************************************************************************/
PVRShell* NewDemo() PVRShell* NewDemo()
{ {
return new OGLES2ColourGrading(); return new OGLES3ColourGrading();
} }
/****************************************************************************** /******************************************************************************
End of file (OGLES2ColourGrading.cpp) End of file (OGLES3ColourGrading.cpp)
******************************************************************************/ ******************************************************************************/
uniform sampler2D sTexture; uniform sampler2D sTexture;
varying lowp vec3 DiffuseLight; varying lowp vec3 DiffuseLight;
varying lowp vec3 SpecularLight; varying lowp vec3 SpecularLight;
varying mediump vec2 TexCoord; varying mediump vec2 TexCoord;
void main() void main()
{ {
lowp vec3 texColor = texture2D(sTexture, TexCoord).rgb; lowp vec3 texColor = texture2D(sTexture, TexCoord).rgb;
lowp vec3 color = (texColor * DiffuseLight) + SpecularLight; lowp vec3 color = (texColor * DiffuseLight) + SpecularLight;
gl_FragColor = vec4(color, 1.0); gl_FragColor = vec4(color, 1.0);
} }
......
attribute highp vec4 inVertex; attribute highp vec4 inVertex;
attribute highp vec3 inNormal; attribute highp vec3 inNormal;
attribute highp vec2 inTexCoord; attribute highp vec2 inTexCoord;
uniform highp mat4 MVPMatrix; uniform highp mat4 MVPMatrix;
uniform highp vec3 LightDirection; uniform highp vec3 LightDirection;
uniform highp float MaterialBias; uniform highp float MaterialBias;
uniform highp float MaterialScale; uniform highp float MaterialScale;
varying lowp vec3 DiffuseLight; varying lowp vec3 DiffuseLight;
varying lowp vec3 SpecularLight; varying lowp vec3 SpecularLight;
varying mediump vec2 TexCoord; varying mediump vec2 TexCoord;
void main() void main()
{ {
......
#version 300 es
#define VERTEX_ARRAY 0
#define TEXCOORD_ARRAY 1
layout (location = VERTEX_ARRAY) in highp vec4 inVertex;
layout (location = TEXCOORD_ARRAY) in mediump vec2 inTexCoord;
out mediump vec2 texCoords;
void main()
{
gl_Position = inVertex;
texCoords = inTexCoord;
}
...@@ -68,37 +68,37 @@ $(CONTENTDIR)/SceneVertShader.cpp: $(CONTENTDIR) ./SceneVertShader.vsh ...@@ -68,37 +68,37 @@ $(CONTENTDIR)/SceneVertShader.cpp: $(CONTENTDIR) ./SceneVertShader.vsh
$(CONTENTDIR)/BackgroundFragShader.cpp: $(CONTENTDIR) ./BackgroundFragShader.fsh $(CONTENTDIR)/BackgroundFragShader.cpp: $(CONTENTDIR) ./BackgroundFragShader.fsh
$(FILEWRAP) -s -o $@ ./BackgroundFragShader.fsh $(FILEWRAP) -s -o $@ ./BackgroundFragShader.fsh
$(CONTENTDIR)/Mask.cpp: $(CONTENTDIR) $(CONTENTDIR)/Mask.cpp: $(CONTENTDIR) ./Mask.pod
$(FILEWRAP) -o $@ ./Mask.pod $(FILEWRAP) -o $@ ./Mask.pod
$(CONTENTDIR)/MaskTexture.cpp: $(CONTENTDIR) $(CONTENTDIR)/MaskTexture.cpp: $(CONTENTDIR) ./MaskTexture.pvr
$(FILEWRAP) -o $@ ./MaskTexture.pvr $(FILEWRAP) -o $@ ./MaskTexture.pvr
$(CONTENTDIR)/Background.cpp: $(CONTENTDIR) $(CONTENTDIR)/Background.cpp: $(CONTENTDIR) ./Background.pvr
$(FILEWRAP) -o $@ ./Background.pvr $(FILEWRAP) -o $@ ./Background.pvr
$(CONTENTDIR)/identity.cpp: $(CONTENTDIR) $(CONTENTDIR)/identity.cpp: $(CONTENTDIR) ./identity.pvr
$(FILEWRAP) -o $@ ./identity.pvr $(FILEWRAP) -o $@ ./identity.pvr
$(CONTENTDIR)/cooler.cpp: $(CONTENTDIR) $(CONTENTDIR)/cooler.cpp: $(CONTENTDIR) ./cooler.pvr
$(FILEWRAP) -o $@ ./cooler.pvr $(FILEWRAP) -o $@ ./cooler.pvr
$(CONTENTDIR)/warmer.cpp: $(CONTENTDIR) $(CONTENTDIR)/warmer.cpp: $(CONTENTDIR) ./warmer.pvr
$(FILEWRAP) -o $@ ./warmer.pvr $(FILEWRAP) -o $@ ./warmer.pvr
$(CONTENTDIR)/bw.cpp: $(CONTENTDIR) $(CONTENTDIR)/bw.cpp: $(CONTENTDIR) ./bw.pvr
$(FILEWRAP) -o $@ ./bw.pvr $(FILEWRAP) -o $@ ./bw.pvr
$(CONTENTDIR)/sepia.cpp: $(CONTENTDIR) $(CONTENTDIR)/sepia.cpp: $(CONTENTDIR) ./sepia.pvr
$(FILEWRAP) -o $@ ./sepia.pvr $(FILEWRAP) -o $@ ./sepia.pvr
$(CONTENTDIR)/inverted.cpp: $(CONTENTDIR) $(CONTENTDIR)/inverted.cpp: $(CONTENTDIR) ./inverted.pvr
$(FILEWRAP) -o $@ ./inverted.pvr $(FILEWRAP) -o $@ ./inverted.pvr
$(CONTENTDIR)/highcontrast.cpp: $(CONTENTDIR) $(CONTENTDIR)/highcontrast.cpp: $(CONTENTDIR) ./highcontrast.pvr
$(FILEWRAP) -o $@ ./highcontrast.pvr $(FILEWRAP) -o $@ ./highcontrast.pvr
$(CONTENTDIR)/bluewhitegradient.cpp: $(CONTENTDIR) $(CONTENTDIR)/bluewhitegradient.cpp: $(CONTENTDIR) ./bluewhitegradient.pvr
$(FILEWRAP) -o $@ ./bluewhitegradient.pvr $(FILEWRAP) -o $@ ./bluewhitegradient.pvr
############################################################################ ############################################################################
......
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OGLES3Tools", "OGLES3Tools.vcxproj", "{09ABE661-9BC0-4152-A820-1FB0522CAC01}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|Win32.ActiveCfg = Debug|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|Win32.Build.0 = Debug|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|x64.ActiveCfg = Debug|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Debug|x64.Build.0 = Debug|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|Win32.ActiveCfg = Release|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|Win32.Build.0 = Release|Win32
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.ActiveCfg = Release|x64
{09ABE661-9BC0-4152-A820-1FB0522CAC01}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9088FC9E-9843-4E0D-85D0-1B657AFC480A}</ProjectGuid>
<RootNamespace>OGLES3Tools</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\OGLES2;..\..;..\..\..;..\..\..\..\Builds\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\OGLES2;..\..;..\..\..;..\..\..\..\Builds\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\OGLES2;..\..;..\..\..;..\..\..\..\Builds\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\OGLES2;..\..;..\..\..;..\..\..\..\Builds\Include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;BUILD_OGLES3;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\OGLES2\PVRTBackground.cpp" />
<ClCompile Include="..\..\..\PVRTDecompress.cpp" />
<ClCompile Include="..\..\..\PVRTError.cpp" />
<ClCompile Include="..\..\..\PVRTFixedPoint.cpp" />
<ClCompile Include="..\..\..\PVRTMatrixF.cpp" />
<ClCompile Include="..\..\..\PVRTMatrixX.cpp" />
<ClCompile Include="..\..\..\PVRTMisc.cpp" />
<ClCompile Include="..\..\..\PVRTModelPOD.cpp" />
<ClCompile Include="..\..\..\PVRTPFXParser.cpp" />
<ClCompile Include="..\..\..\OGLES2\PVRTPFXParserAPI.cpp" />
<ClCompile Include="..\..\..\OGLES2\PVRTPFXSemantics.cpp" />
<ClCompile Include="..\..\..\PVRTPrint3D.cpp" />
<ClCompile Include="..\..\..\OGLES2\PVRTPrint3DAPI.cpp" />
<ClCompile Include="..\..\..\PVRTQuaternionF.cpp" />
<ClCompile Include="..\..\..\PVRTQuaternionX.cpp" />
<ClCompile Include="..\..\..\PVRTResourceFile.cpp" />
<ClCompile Include="..\..\..\OGLES2\PVRTShader.cpp" />
<ClCompile Include="..\..\..\PVRTShadowVol.cpp" />
<ClCompile Include="..\..\..\PVRTString.cpp" />
<ClCompile Include="..\..\..\PVRTStringHash.cpp" />
<ClCompile Include="..\..\..\PVRTTexture.cpp" />
<ClCompile Include="..\..\PVRTTextureAPI.cpp" />
<ClCompile Include="..\..\PVRTgles3Ext.cpp" />
<ClCompile Include="..\..\..\PVRTTrans.cpp" />
<ClCompile Include="..\..\..\PVRTTriStrip.cpp" />
<ClCompile Include="..\..\..\PVRTUnicode.cpp" />
<ClCompile Include="..\..\..\PVRTVector.cpp" />
<ClCompile Include="..\..\..\PVRTVertex.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\OGLES3Tools.h" />
<ClInclude Include="..\..\..\PVRTArray.h" />
<ClInclude Include="..\..\..\PVRTBackground.h" />
<ClInclude Include="..\..\..\OGLES2\PVRTBackgroundShaders.h" />
<ClInclude Include="..\..\..\PVRTBoneBatch.h" />
<ClInclude Include="..\..\..\OGLES2\PVRTContext.h" />
<ClInclude Include="..\..\..\PVRTDecompress.h" />
<ClInclude Include="..\..\..\PVRTError.h" />
<ClInclude Include="..\..\..\PVRTFixedPoint.h" />
<ClInclude Include="..\..\..\PVRTGlobal.h" />
<ClInclude Include="..\..\..\PVRTHash.h" />
<ClInclude Include="..\..\..\PVRTMap.h" />
<ClInclude Include="..\..\..\PVRTMatrix.h" />
<ClInclude Include="..\..\..\PVRTMemoryFileSystem.h" />
<ClInclude Include="..\..\..\PVRTMisc.h" />
<ClInclude Include="..\..\..\PVRTModelPOD.h" />
<ClInclude Include="..\..\..\PVRTPFXParser.h" />
<ClInclude Include="..\..\..\OGLES2\PVRTPFXParserAPI.h" />
<ClInclude Include="..\..\..\OGLES2\PVRTPFXSemantics.h" />
<ClInclude Include="..\..\..\PVRTPrint3D.h" />
<ClInclude Include="..\..\..\OGLES2\PVRTPrint3DShaders.h" />
<ClInclude Include="..\..\..\PVRTQuaternion.h" />
<ClInclude Include="..\..\..\PVRTResourceFile.h" />
<ClInclude Include="..\..\..\OGLES2\PVRTShader.h" />
<ClInclude Include="..\..\..\PVRTShadowVol.h" />
<ClInclude Include="..\..\..\PVRTString.h" />
<ClInclude Include="..\..\..\PVRTStringHash.h" />
<ClInclude Include="..\..\..\PVRTTexture.h" />
<ClInclude Include="..\..\PVRTTextureAPI.h" />
<ClInclude Include="..\..\PVRTgles3Ext.h" />
<ClInclude Include="..\..\..\PVRTTrans.h" />
<ClInclude Include="..\..\..\PVRTTriStrip.h" />
<ClInclude Include="..\..\..\PVRTUnicode.h" />
<ClInclude Include="..\..\..\PVRTVector.h" />
<ClInclude Include="..\..\..\PVRTVertex.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\BackgroundFragShader.fsh" />
<None Include="..\..\BackgroundVertShader.vsh" />
<None Include="..\..\Print3DFragShader.fsh" />
<None Include="..\..\Print3DVertShader.vsh" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{2f974aff-a0c6-4c10-b98e-86f39b6db949}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{f02fbd4c-76ba-4991-8d59-d3d715f96754}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions>
</Filter>
<Filter Include="Shader Files">
<UniqueIdentifier>{22ea3143-7c3f-4b2f-a437-f17e46999700}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\OGLES2\PVRTBackground.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTDecompress.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTError.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTFixedPoint.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTMatrixF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTMatrixX.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTMisc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTModelPOD.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTPFXParser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\OGLES2\PVRTPFXParserAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\OGLES2\PVRTPFXSemantics.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTPrint3D.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\OGLES2\PVRTPrint3DAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTQuaternionF.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTQuaternionX.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTResourceFile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\OGLES2\PVRTShader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTShadowVol.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTString.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTStringHash.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTTexture.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\PVRTTextureAPI.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\PVRTgles3Ext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTTrans.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTTriStrip.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTUnicode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTVector.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\PVRTVertex.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\OGLES3Tools.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTArray.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTBackground.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\OGLES2\PVRTBackgroundShaders.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTBoneBatch.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\OGLES2\PVRTContext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTDecompress.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTError.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTFixedPoint.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTGlobal.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTHash.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTMap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTMatrix.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTMemoryFileSystem.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTMisc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTModelPOD.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTPFXParser.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\OGLES2\PVRTPFXParserAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTPrint3D.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\OGLES2\PVRTPrint3DShaders.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTQuaternion.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTResourceFile.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\OGLES2\PVRTShader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTShadowVol.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTString.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTStringHash.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTTexture.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\PVRTTextureAPI.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\PVRTgles3Ext.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTTrans.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTTriStrip.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTUnicode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTVector.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\PVRTVertex.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\OGLES2\PVRTPFXSemantics.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\BackgroundFragShader.fsh">
<Filter>Shader Files</Filter>
</None>
<None Include="..\..\BackgroundVertShader.vsh">
<Filter>Shader Files</Filter>
</None>
<None Include="..\..\Print3DFragShader.fsh">
<Filter>Shader Files</Filter>
</None>
<None Include="..\..\Print3DVertShader.vsh">
<Filter>Shader Files</Filter>
</None>
</ItemGroup>
</Project>
\ No newline at end of file
/*!****************************************************************************
@file OGLES3/OGLES31Tools.h
@ingroup API_OGLES3
@copyright Copyright (c) Imagination Technologies Limited.
@brief Header file of OGLES3Tools.lib.
******************************************************************************/
#ifndef _OGLES31TOOLS_H_
#define _OGLES31TOOLS_H_
#ifndef BUILD_OGLES31
#define BUILD_OGLES31
#endif
#include<OGLES3Tools.h>
#endif /* _OGLES31TOOLS_H_ */
/*****************************************************************************
End of file (OGLES31Tools.h)
*****************************************************************************/
/*!****************************************************************************
@file OGLES3/OGLES3Tools.h
@ingroup API_OGLES3
@copyright Copyright (c) Imagination Technologies Limited.
@brief Header file of OGLES3Tools.lib.
******************************************************************************/
#ifndef _OGLES3TOOLS_H_
#define _OGLES3TOOLS_H_
/*!
@addtogroup API_OGLES3
@brief Tools for the OpenGL ES 3.0 API.
*/
#ifndef BUILD_OGLES3
#define BUILD_OGLES3
#endif
#include "../OGLES2/PVRTContext.h"
#include "../PVRTGlobal.h"
#include "../PVRTArray.h"
#include "../PVRTHash.h"
#include "../PVRTVector.h"
#include "../PVRTString.h"
#include "../PVRTStringHash.h"
#include "../PVRTFixedPoint.h"
#include "../PVRTMatrix.h"
#include "../PVRTQuaternion.h"
#include "../PVRTTrans.h"
#include "../PVRTVertex.h"
#include "../PVRTMap.h"
#include "../PVRTMisc.h"
#include "../PVRTBackground.h"
#include "PVRTgles3Ext.h"
#include "../PVRTPrint3D.h"
#include "../PVRTBoneBatch.h"
#include "../PVRTModelPOD.h"
#include "../PVRTTexture.h"
#include "PVRTTextureAPI.h"
#include "../PVRTTriStrip.h"
#include "../OGLES2/PVRTShader.h"
#include "../PVRTPFXParser.h"
#include "../OGLES2/PVRTPFXParserAPI.h"
#include "../OGLES2/PVRTPFXSemantics.h"
#include "../PVRTShadowVol.h"
#include "../PVRTResourceFile.h"
#include "../PVRTError.h"
#endif /* _OGLES3TOOLS_H_ */
/*****************************************************************************
End of file (OGLES3Tools.h)
*****************************************************************************/
/******************************************************************************
@File OGLES3/PVRTTextureAPI.cpp
@Title OGLES3/PVRTTextureAPI
@Version
@Copyright Copyright (c) Imagination Technologies Limited.
@Platform ANSI compatible
@Description OGLES3 texture loading.
******************************************************************************/
#include <string.h>
#include <stdlib.h>
#include "PVRTContext.h"
#include "PVRTgles3Ext.h"
#include "PVRTTexture.h"
#include "PVRTTextureAPI.h"
#include "PVRTDecompress.h"
#include "PVRTFixedPoint.h"
#include "PVRTMap.h"
#include "PVRTMatrix.h"
#include "PVRTMisc.h"
#include "PVRTResourceFile.h"
/*****************************************************************************
** Functions
****************************************************************************/
/*!***********************************************************************
@Function: PVRTGetOGLES3TextureFormat
@Input: sTextureHeader
@Modified: glInternalFormat
@Modified: glFormat
@Modified: glType
@Description: Gets the OpenGLES equivalent values of internal format,
format and type for this texture header. This will return
any supported OpenGLES texture values, it is up to the user
to decide if these are valid for their current platform.
*************************************************************************/
static const void PVRTGetOGLES3TextureFormat(const PVRTextureHeaderV3& sTextureHeader, PVRTuint32& glInternalFormat, PVRTuint32& glFormat, PVRTuint32& glType)
{
PVRTuint64 PixelFormat = sTextureHeader.u64PixelFormat;
EPVRTVariableType ChannelType = (EPVRTVariableType)sTextureHeader.u32ChannelType;
EPVRTColourSpace ColourSpace = (EPVRTColourSpace)sTextureHeader.u32ColourSpace;
//Initialisation. Any invalid formats will return 0 always.
glFormat = 0;
glType = 0;
glInternalFormat=0;
//Get the last 32 bits of the pixel format.
PVRTuint64 PixelFormatPartHigh = PixelFormat&PVRTEX_PFHIGHMASK;
//Check for a compressed format (The first 8 bytes will be 0, so the whole thing will be equal to the last 32 bits).
if (PixelFormatPartHigh==0)
{
//Format and type == 0 for compressed textures.
switch (PixelFormat)
{
case ePVRTPF_PVRTCI_2bpp_RGB:
{
if (ColourSpace == ePVRTCSpacesRGB)
{
//glInternalFormat=GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT;
}
else
{
glInternalFormat=GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
}
return;
}
case ePVRTPF_PVRTCI_2bpp_RGBA:
{
if (ColourSpace == ePVRTCSpacesRGB)
{
//glInternalFormat=GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT;
}
else
{
glInternalFormat=GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
}
return;
}
case ePVRTPF_PVRTCI_4bpp_RGB:
{
if (ColourSpace == ePVRTCSpacesRGB)
{
//glInternalFormat=GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT;
}
else
{
glInternalFormat=GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
}
return;
}
case ePVRTPF_PVRTCI_4bpp_RGBA:
{
if (ColourSpace == ePVRTCSpacesRGB)
{
//glInternalFormat=GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT;
}
else
{
glInternalFormat=GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
}
return;
}
#ifndef TARGET_OS_IPHONE
case ePVRTPF_PVRTCII_2bpp:
{
if (ColourSpace == ePVRTCSpacesRGB)
{
//glInternalFormat=GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG;
}
else
{
glInternalFormat=GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG;
}
return;
}
case ePVRTPF_PVRTCII_4bpp:
{
if (ColourSpace == ePVRTCSpacesRGB)
{
//glInternalFormat=GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG;
}
else
{
glInternalFormat=GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG;
}
return;
}
case ePVRTPF_ETC1:
{
glInternalFormat=GL_ETC1_RGB8_OES;
return;
}
#endif
case ePVRTPF_ETC2_RGB:
{
if (ColourSpace==ePVRTCSpacesRGB)
glInternalFormat=GL_COMPRESSED_SRGB8_ETC2;
else
glInternalFormat=GL_COMPRESSED_RGB8_ETC2;
return;
}
case ePVRTPF_ETC2_RGBA:
{
if (ColourSpace==ePVRTCSpacesRGB)
glInternalFormat=GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC;
else
glInternalFormat=GL_COMPRESSED_RGBA8_ETC2_EAC;
return;
}
case ePVRTPF_ETC2_RGB_A1:
{
if (ColourSpace==ePVRTCSpacesRGB)
glInternalFormat=GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2;
else
glInternalFormat=GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2;
return;
}
case ePVRTPF_EAC_R11:
{
if (ChannelType==ePVRTVarTypeSignedInteger || ChannelType==ePVRTVarTypeSignedIntegerNorm ||
ChannelType==ePVRTVarTypeSignedShort || ChannelType==ePVRTVarTypeSignedShortNorm ||
ChannelType==ePVRTVarTypeSignedByte || ChannelType==ePVRTVarTypeSignedByteNorm ||
ChannelType==ePVRTVarTypeSignedFloat)
{
glInternalFormat=GL_COMPRESSED_SIGNED_R11_EAC;
}
else
{
glInternalFormat=GL_COMPRESSED_R11_EAC;
}
return;
}
case ePVRTPF_EAC_RG11:
{
if (ChannelType==ePVRTVarTypeSignedInteger || ChannelType==ePVRTVarTypeSignedIntegerNorm ||
ChannelType==ePVRTVarTypeSignedShort || ChannelType==ePVRTVarTypeSignedShortNorm ||
ChannelType==ePVRTVarTypeSignedByte || ChannelType==ePVRTVarTypeSignedByteNorm ||
ChannelType==ePVRTVarTypeSignedFloat)
{
glInternalFormat=GL_COMPRESSED_SIGNED_RG11_EAC;
}
else
{
glInternalFormat=GL_COMPRESSED_RG11_EAC;
}
return;
}
}
}
else
{
switch (ChannelType)
{
case ePVRTVarTypeUnsignedFloat:
if (PixelFormat==PVRTGENPIXELID3('r','g','b',11,11,10) )
{
glType=GL_UNSIGNED_INT_10F_11F_11F_REV;
glFormat = GL_RGB;
glInternalFormat=GL_R11F_G11F_B10F;
return;
}
break;
case ePVRTVarTypeSignedFloat:
{
switch (PixelFormat)
{
//HALF_FLOAT
case PVRTGENPIXELID4('r','g','b','a',16,16,16,16):
{
glType=GL_HALF_FLOAT;
glFormat = GL_RGBA;
glInternalFormat=GL_RGBA;
return;
}
case PVRTGENPIXELID3('r','g','b',16,16,16):
{
glType=GL_HALF_FLOAT;
glFormat = GL_RGB;
glInternalFormat=GL_RGB16F;
return;
}
case PVRTGENPIXELID2('r','g',16,16):
{
glType=GL_HALF_FLOAT;
glFormat = GL_RG;
glInternalFormat=GL_RG16F;
return;
}
case PVRTGENPIXELID1('r',16):
{
glType=GL_HALF_FLOAT;
glFormat = GL_RED;
glInternalFormat=GL_R16F;
return;
}
case PVRTGENPIXELID2('l','a',16,16):
{
glType=GL_HALF_FLOAT;
glFormat = GL_LUMINANCE_ALPHA;
glInternalFormat=GL_LUMINANCE_ALPHA;
return;
}
case PVRTGENPIXELID1('l',16):
{
glType=GL_HALF_FLOAT;
glFormat = GL_LUMINANCE;
glInternalFormat=GL_LUMINANCE;
return;
}
case PVRTGENPIXELID1('a',16):
{
glType=GL_HALF_FLOAT;
glFormat = GL_ALPHA;
glInternalFormat=GL_ALPHA;
return;
}
//FLOAT
case PVRTGENPIXELID4('r','g','b','a',32,32,32,32):
{
glType=GL_FLOAT;
glFormat = GL_RGBA;
glInternalFormat=GL_RGBA32F;
return;
}
case PVRTGENPIXELID3('r','g','b',32,32,32):
{
glType=GL_FLOAT;
glFormat = GL_RGB;
glInternalFormat=GL_RGB32F;
return;
}
case PVRTGENPIXELID2('r','g',32,32):
{
glType=GL_FLOAT;
glFormat = GL_RG;
glInternalFormat=GL_RG32F;
return;
}
case PVRTGENPIXELID1('r',32):
{
glType=GL_FLOAT;
glFormat = GL_RED;
glInternalFormat=GL_R32F;
return;
}
case PVRTGENPIXELID2('l','a',32,32):
{
glType=GL_FLOAT;
glFormat = GL_LUMINANCE_ALPHA;
glInternalFormat=GL_LUMINANCE_ALPHA;
return;
}
case PVRTGENPIXELID1('l',32):
{
glType=GL_FLOAT;
glFormat = GL_LUMINANCE;
glInternalFormat=GL_LUMINANCE;
return;
}
case PVRTGENPIXELID1('a',32):
{
glType=GL_FLOAT;
glFormat = GL_ALPHA;
glInternalFormat=GL_ALPHA;
return;
}
}
break;
}
case ePVRTVarTypeUnsignedByteNorm:
{
glType = GL_UNSIGNED_BYTE;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',8,8,8,8):
{
glFormat = GL_RGBA;
if (ColourSpace==ePVRTCSpacesRGB)
glInternalFormat=GL_SRGB8_ALPHA8;
else
glInternalFormat=GL_RGBA8;
return;
}
case PVRTGENPIXELID3('r','g','b',8,8,8):
{
glFormat = GL_RGB;
if (ColourSpace==ePVRTCSpacesRGB)
glInternalFormat=GL_SRGB8;
else
glInternalFormat=GL_RGB8;
return;
}
case PVRTGENPIXELID2('r','g',8,8):
{
glFormat = GL_RG;
glInternalFormat=GL_RG8;
return;
}
case PVRTGENPIXELID1('r',8):
{
glFormat = GL_RED;
glInternalFormat=GL_R8;
return;
}
case PVRTGENPIXELID2('l','a',8,8):
{
glFormat = GL_LUMINANCE_ALPHA;
glInternalFormat=GL_LUMINANCE_ALPHA;
return;
}
case PVRTGENPIXELID1('l',8):
{
glFormat = GL_LUMINANCE;
glInternalFormat=GL_LUMINANCE;
return;
}
case PVRTGENPIXELID1('a',8):
{
glFormat = GL_ALPHA;
glInternalFormat=GL_ALPHA;
return;
}
case PVRTGENPIXELID4('b','g','r','a',8,8,8,8):
{
glFormat = GL_BGRA_EXT;
glInternalFormat=GL_BGRA_EXT;
return;
}
}
break;
}
case ePVRTVarTypeSignedByteNorm:
{
glType = GL_BYTE;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',8,8,8,8):
{
glFormat = GL_RGBA;
glInternalFormat=GL_RGBA8_SNORM;
return;
}
case PVRTGENPIXELID3('r','g','b',8,8,8):
{
glFormat = GL_RGB;
glInternalFormat=GL_RGB8_SNORM;
return;
}
case PVRTGENPIXELID2('r','g',8,8):
{
glFormat = GL_RG;
glInternalFormat=GL_RGB8_SNORM;
return;
}
case PVRTGENPIXELID1('r',8):
{
glFormat = GL_RED;
glInternalFormat=GL_R8_SNORM;
return;
}
}
break;
}
case ePVRTVarTypeUnsignedByte:
{
glType = GL_UNSIGNED_BYTE;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',8,8,8,8):
{
glFormat = GL_RGBA_INTEGER;
glInternalFormat=GL_RGBA8UI;
return;
}
case PVRTGENPIXELID3('r','g','b',8,8,8):
{
glFormat = GL_RGB_INTEGER;
glInternalFormat=GL_RGB8UI;
return;
}
case PVRTGENPIXELID2('r','g',8,8):
{
glFormat = GL_RG_INTEGER;
glInternalFormat=GL_RG8UI;
return;
}
case PVRTGENPIXELID1('r',8):
{
glFormat = GL_RED_INTEGER;
glInternalFormat=GL_R8UI;
return;
}
}
break;
}
case ePVRTVarTypeSignedByte:
{
glType = GL_BYTE;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',8,8,8,8):
{
glFormat = GL_RGBA_INTEGER;
glInternalFormat=GL_RGBA8I;
return;
}
case PVRTGENPIXELID3('r','g','b',8,8,8):
{
glFormat = GL_RGB_INTEGER;
glInternalFormat=GL_RGB8I;
return;
}
case PVRTGENPIXELID2('r','g',8,8):
{
glFormat = GL_RG_INTEGER;
glInternalFormat=GL_RG8I;
return;
}
case PVRTGENPIXELID1('r',8):
{
glFormat = GL_RED_INTEGER;
glInternalFormat=GL_R8I;
return;
}
}
break;
}
case ePVRTVarTypeUnsignedShortNorm:
{
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',4,4,4,4):
{
glType = GL_UNSIGNED_SHORT_4_4_4_4;
glFormat = GL_RGBA;
glInternalFormat=GL_RGBA4;
return;
}
case PVRTGENPIXELID4('r','g','b','a',5,5,5,1):
{
glType = GL_UNSIGNED_SHORT_5_5_5_1;
glFormat = GL_RGBA;
glInternalFormat=GL_RGB5_A1;
return;
}
case PVRTGENPIXELID3('r','g','b',5,6,5):
{
glType = GL_UNSIGNED_SHORT_5_6_5;
glFormat = GL_RGB;
glInternalFormat=GL_RGB565;
return;
}
}
break;
}
case ePVRTVarTypeUnsignedShort:
{
glType = GL_UNSIGNED_SHORT;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',16,16,16,16):
{
glFormat = GL_RGBA_INTEGER;
glInternalFormat=GL_RGBA16UI;
return;
}
case PVRTGENPIXELID3('r','g','b',16,16,16):
{
glFormat = GL_RGB_INTEGER;
glInternalFormat=GL_RGB16UI;
return;
}
case PVRTGENPIXELID2('r','g',16,16):
{
glFormat = GL_RG_INTEGER;
glInternalFormat=GL_RG16UI;
return;
}
case PVRTGENPIXELID1('r',16):
{
glFormat = GL_RED_INTEGER;
glInternalFormat=GL_R16UI;
return;
}
}
break;
}
case ePVRTVarTypeSignedShort:
{
glType = GL_SHORT;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',16,16,16,16):
{
glFormat = GL_RGBA_INTEGER;
glInternalFormat=GL_RGBA16I;
return;
}
case PVRTGENPIXELID3('r','g','b',16,16,16):
{
glFormat = GL_RGB_INTEGER;
glInternalFormat=GL_RGB16I;
return;
}
case PVRTGENPIXELID2('r','g',16,16):
{
glFormat = GL_RG_INTEGER;
glInternalFormat=GL_RG16I;
return;
}
case PVRTGENPIXELID1('r',16):
{
glFormat = GL_RED_INTEGER;
glInternalFormat=GL_R16I;
return;
}
}
break;
}
case ePVRTVarTypeUnsignedIntegerNorm:
{
if (PixelFormat==PVRTGENPIXELID4('a','b','g','r',2,10,10,10))
{
glType = GL_UNSIGNED_INT_2_10_10_10_REV;
glFormat = GL_RGBA;
glInternalFormat=GL_RGB10_A2;
return;
}
break;
}
case ePVRTVarTypeUnsignedInteger:
{
glType = GL_UNSIGNED_INT;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',32,32,32,32):
{
glFormat = GL_RGBA_INTEGER;
glInternalFormat=GL_RGBA32UI;
return;
}
case PVRTGENPIXELID3('r','g','b',32,32,32):
{
glFormat = GL_RGB_INTEGER;
glInternalFormat=GL_RGB32UI;
return;
}
case PVRTGENPIXELID2('r','g',32,32):
{
glFormat = GL_RG_INTEGER;
glInternalFormat=GL_RG32UI;
return;
}
case PVRTGENPIXELID1('r',32):
{
glFormat = GL_RED_INTEGER;
glInternalFormat=GL_R32UI;
return;
}
case PVRTGENPIXELID4('a','b','g','r',2,10,10,10):
{
glType = GL_UNSIGNED_INT_2_10_10_10_REV;
glFormat = GL_RGBA_INTEGER;
glInternalFormat=GL_RGB10_A2UI;
return;
}
}
break;
}
case ePVRTVarTypeSignedInteger:
{
glType = GL_INT;
switch (PixelFormat)
{
case PVRTGENPIXELID4('r','g','b','a',32,32,32,32):
{
glFormat = GL_RGBA_INTEGER;
glInternalFormat=GL_RGBA32I;
return;
}
case PVRTGENPIXELID3('r','g','b',32,32,32):
{
glFormat = GL_RGB_INTEGER;
glInternalFormat=GL_RGB32I;
return;
}
case PVRTGENPIXELID2('r','g',32,32):
{
glFormat = GL_RG_INTEGER;
glInternalFormat=GL_RG32I;
return;
}
case PVRTGENPIXELID1('r',32):
{
glFormat = GL_RED_INTEGER;
glInternalFormat=GL_R32I;
return;
}
}
break;
}
default: { }
}
}
//Default (erroneous) return values.
glType = glFormat = glInternalFormat = 0;
}
/*!***************************************************************************
@Function PVRTTextureTile
@Modified pOut The tiled texture in system memory
@Input pIn The source texture
@Input nRepeatCnt Number of times to repeat the source texture
@Description Allocates and fills, in system memory, a texture large enough
to repeat the source texture specified number of times.
*****************************************************************************/
void PVRTTextureTile(
PVRTextureHeaderV3 **pOut,
const PVRTextureHeaderV3 * const pIn,
const int nRepeatCnt)
{
unsigned int nFormat = 0, nType = 0, nBPP, nSize, nElW = 0, nElH = 0, nElD = 0;
PVRTuint8 *pMmSrc, *pMmDst;
unsigned int nLevel;
PVRTextureHeaderV3 *psTexHeaderNew;
_ASSERT(pIn->u32Width);
_ASSERT(pIn->u32Width == pIn->u32Height);
_ASSERT(nRepeatCnt > 1);
PVRTGetOGLES3TextureFormat(*pIn,nFormat,nFormat,nType);
PVRTGetFormatMinDims(pIn->u64PixelFormat,nElW,nElH,nElD);
nBPP = PVRTGetBitsPerPixel(pIn->u64PixelFormat);
nSize = pIn->u32Width * nRepeatCnt;
psTexHeaderNew = PVRTTextureCreate(nSize, nSize, nElW, nElH, nBPP, true);
*psTexHeaderNew = *pIn;
pMmDst = (PVRTuint8*)psTexHeaderNew + sizeof(*psTexHeaderNew);
pMmSrc = (PVRTuint8*)pIn + sizeof(*pIn);
for(nLevel = 0; ((unsigned int)1 << nLevel) < nSize; ++nLevel)
{
int nBlocksDstW = PVRT_MAX((unsigned int)1, (nSize >> nLevel) / nElW);
int nBlocksDstH = PVRT_MAX((unsigned int)1, (nSize >> nLevel) / nElH);
int nBlocksSrcW = PVRT_MAX((unsigned int)1, (pIn->u32Width >> nLevel) / nElW);
int nBlocksSrcH = PVRT_MAX((unsigned int)1, (pIn->u32Height >> nLevel) / nElH);
int nBlocksS = nBPP * nElW * nElH / 8;
PVRTTextureLoadTiled(
pMmDst,
nBlocksDstW,
nBlocksDstH,
pMmSrc,
nBlocksSrcW,
nBlocksSrcH,
nBlocksS,
(pIn->u64PixelFormat>=ePVRTPF_PVRTCI_2bpp_RGB && pIn->u64PixelFormat<=ePVRTPF_PVRTCI_4bpp_RGBA) ? true : false);
pMmDst += nBlocksDstW * nBlocksDstH * nBlocksS;
pMmSrc += nBlocksSrcW * nBlocksSrcH * nBlocksS;
}
psTexHeaderNew->u32Width = nSize;
psTexHeaderNew->u32Height = nSize;
psTexHeaderNew->u32MIPMapCount = nLevel+1;
*pOut = psTexHeaderNew;
}
/*!***************************************************************************
@Function PVRTTextureLoadFromPointer
@Input pointer Pointer to header-texture's structure
@Modified texName the OpenGL ES texture name as returned by glBindTexture
@Modified psTextureHeader Pointer to a PVRTextureHeaderV3 struct. Modified to
contain the header data of the returned texture Ignored if NULL.
@Input bAllowDecompress Allow decompression if PVRTC is not supported in hardware.
@Input nLoadFromLevel Which mip map level to start loading from (0=all)
@Input texPtr If null, texture follows header, else texture is here.
@Modified pMetaData If a valid map is supplied, this will return any and all
MetaDataBlocks stored in the texture, organised by DevFourCC
then identifier. Supplying NULL will ignore all MetaData.
@Return PVR_SUCCESS on success
@Description Allows textures to be stored in C header files and loaded in. Can load parts of a
mip mapped texture (i.e. skipping the highest detailed levels). In OpenGL Cube Map, each
texture's up direction is defined as next (view direction, up direction),
(+x,-y)(-x,-y)(+y,+z)(-y,-z)(+z,-y)(-z,-y).
Sets the texture MIN/MAG filter to GL_LINEAR_MIPMAP_NEAREST/GL_LINEAR
if mip maps are present, GL_LINEAR/GL_LINEAR otherwise.
*****************************************************************************/
EPVRTError PVRTTextureLoadFromPointer( const void* pointer,
GLuint *const texName,
const void *psTextureHeader,
bool bAllowDecompress,
const unsigned int nLoadFromLevel,
const void * const texPtr,
CPVRTMap<unsigned int, CPVRTMap<unsigned int, MetaDataBlock> > *pMetaData)
{
//Compression bools
bool bIsCompressedFormatSupported=false;
bool bIsCompressedFormat=false;
bool bIsLegacyPVR=false;
bool bUsesTexImage3D=false;
//Texture setup
PVRTextureHeaderV3 sTextureHeader;
PVRTuint8* pTextureData=NULL;
//Just in case header and pointer for decompression.
PVRTextureHeaderV3 sTextureHeaderDecomp;
void* pDecompressedData=NULL;
//Check if it's an old header format
if((*(PVRTuint32*)pointer)!=PVRTEX3_IDENT)
{
//Convert the texture header to the new format.
PVRTConvertOldTextureHeaderToV3((PVR_Texture_Header*)pointer,sTextureHeader,pMetaData);
//Get the texture data.
pTextureData = texPtr? (PVRTuint8*)texPtr:(PVRTuint8*)pointer+*(PVRTuint32*)pointer;
bIsLegacyPVR=true;
}
else
{
//Get the header from the main pointer.
sTextureHeader=*(PVRTextureHeaderV3*)pointer;
//Get the texture data.
pTextureData = texPtr? (PVRTuint8*)texPtr:(PVRTuint8*)pointer+PVRTEX3_HEADERSIZE+sTextureHeader.u32MetaDataSize;
if (pMetaData)
{
//Read in all the meta data.
PVRTuint32 metaDataSize=0;
while (metaDataSize<sTextureHeader.u32MetaDataSize)
{
//Read the DevFourCC and advance the pointer offset.
PVRTuint32 DevFourCC=*(PVRTuint32*)((PVRTuint8*)pointer+PVRTEX3_HEADERSIZE+metaDataSize);
metaDataSize+=sizeof(DevFourCC);
//Read the Key and advance the pointer offset.
PVRTuint32 u32Key=*(PVRTuint32*)((PVRTuint8*)pointer+PVRTEX3_HEADERSIZE+metaDataSize);
metaDataSize+=sizeof(u32Key);
//Read the DataSize and advance the pointer offset.
PVRTuint32 u32DataSize = *(PVRTuint32*)((PVRTuint8*)pointer+PVRTEX3_HEADERSIZE+metaDataSize);
metaDataSize+=sizeof(u32DataSize);
//Get the current meta data.
MetaDataBlock& currentMetaData = (*pMetaData)[DevFourCC][u32Key];
//Assign the values to the meta data.
currentMetaData.DevFOURCC=DevFourCC;
currentMetaData.u32Key=u32Key;
currentMetaData.u32DataSize=u32DataSize;
//Check for data, if there is any, read it into the meta data.
if(u32DataSize > 0)
{
//Allocate memory.
currentMetaData.Data = new PVRTuint8[u32DataSize];
//Copy the data.
memcpy(currentMetaData.Data, ((PVRTuint8*)pointer+PVRTEX3_HEADERSIZE+metaDataSize), u32DataSize);
//Advance the meta data size.
metaDataSize+=u32DataSize;
}
}
}
}
//Return the PVRTextureHeader.
if (psTextureHeader)
{
*(PVRTextureHeaderV3*)psTextureHeader=sTextureHeader;
}
//Setup GL Texture format values.
GLenum eTextureFormat = 0;
GLenum eTextureInternalFormat = 0; // often this is the same as textureFormat, but not for BGRA8888 on iOS, for instance
GLenum eTextureType = 0;
//Get the OGLES format values.
PVRTGetOGLES3TextureFormat(sTextureHeader,eTextureInternalFormat,eTextureFormat,eTextureType);
bool bIsPVRTCSupported = CPVRTgles3Ext::IsGLExtensionSupported("GL_IMG_texture_compression_pvrtc");
#ifndef TARGET_OS_IPHONE
bool bIsBGRA8888Supported = CPVRTgles3Ext::IsGLExtensionSupported("GL_IMG_texture_format_BGRA8888");
#else
bool bIsBGRA8888Supported = CPVRTgles3Ext::IsGLExtensionSupported("GL_APPLE_texture_format_BGRA8888");
#endif
#ifndef TARGET_OS_IPHONE
bool bIsETCSupported = CPVRTgles3Ext::IsGLExtensionSupported("GL_OES_compressed_ETC1_RGB8_texture");
#endif
//Check for compressed formats
if (eTextureFormat==0 && eTextureType==0 && eTextureInternalFormat!=0)
{
if (eTextureInternalFormat>=GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG && eTextureInternalFormat<=GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG)
{
//Check for PVRTCI support.
if(bIsPVRTCSupported)
{
bIsCompressedFormatSupported = bIsCompressedFormat = true;
}
else
{
//Try to decompress the texture.
if(bAllowDecompress)
{
//Output a warning.
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer warning: PVRTC not supported. Converting to RGBA8888 instead.\n");
//Modify boolean values.
bIsCompressedFormatSupported = false;
bIsCompressedFormat = true;
//Check if it's 2bpp.
bool bIs2bppPVRTC = (eTextureInternalFormat==GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG || eTextureInternalFormat==GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG);
//Change texture format.
eTextureFormat = eTextureInternalFormat = GL_RGBA;
eTextureType = GL_UNSIGNED_BYTE;
//Create a near-identical texture header for the decompressed header.
sTextureHeaderDecomp = sTextureHeader;
sTextureHeaderDecomp.u32ChannelType=ePVRTVarTypeUnsignedByteNorm;
sTextureHeaderDecomp.u32ColourSpace=ePVRTCSpacelRGB;
sTextureHeaderDecomp.u64PixelFormat=PVRTGENPIXELID4('r','g','b','a',8,8,8,8);
//Allocate enough memory for the decompressed data. OGLES2, so only decompress one surface/face.
pDecompressedData = malloc(PVRTGetTextureDataSize(sTextureHeaderDecomp, PVRTEX_ALLMIPLEVELS, false, true) );
//Check the malloc.
if (!pDecompressedData)
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer error: Unable to allocate memory to decompress texture.\n");
return PVR_FAIL;
}
//Get the dimensions for the current MIP level.
PVRTuint32 uiMIPWidth = sTextureHeaderDecomp.u32Width>>nLoadFromLevel;
PVRTuint32 uiMIPHeight = sTextureHeaderDecomp.u32Height>>nLoadFromLevel;
//Setup temporary variables.
PVRTuint8* pTempDecompData = (PVRTuint8*)pDecompressedData;
PVRTuint8* pTempCompData = (PVRTuint8*)pTextureData;
if (bIsLegacyPVR)
{
//Decompress all the MIP levels.
for (PVRTuint32 uiFace=0;uiFace<sTextureHeader.u32NumFaces;++uiFace)
{
for (PVRTuint32 uiMIPMap=nLoadFromLevel;uiMIPMap<sTextureHeader.u32MIPMapCount;++uiMIPMap)
{
//Get the face offset. Varies per MIP level.
PVRTuint32 decompressedFaceOffset = PVRTGetTextureDataSize(sTextureHeaderDecomp, uiMIPMap, false, false);
PVRTuint32 compressedFaceOffset = PVRTGetTextureDataSize(sTextureHeader, uiMIPMap, false, false);
//Decompress the texture data.
PVRTDecompressPVRTC(pTempCompData,bIs2bppPVRTC?1:0,uiMIPWidth,uiMIPHeight,pTempDecompData);
//Move forward through the pointers.
pTempDecompData+=decompressedFaceOffset;
pTempCompData+=compressedFaceOffset;
//Work out the current MIP dimensions.
uiMIPWidth=PVRT_MAX(1,uiMIPWidth>>1);
uiMIPHeight=PVRT_MAX(1,uiMIPHeight>>1);
}
//Reset the dims.
uiMIPWidth=sTextureHeader.u32Width;
uiMIPHeight=sTextureHeader.u32Height;
}
}
else
{
//Decompress all the MIP levels.
for (PVRTuint32 uiMIPMap=nLoadFromLevel;uiMIPMap<sTextureHeader.u32MIPMapCount;++uiMIPMap)
{
//Get the face offset. Varies per MIP level.
PVRTuint32 decompressedFaceOffset = PVRTGetTextureDataSize(sTextureHeaderDecomp, uiMIPMap, false, false);
PVRTuint32 compressedFaceOffset = PVRTGetTextureDataSize(sTextureHeader, uiMIPMap, false, false);
for (PVRTuint32 uiFace=0;uiFace<sTextureHeader.u32NumFaces;++uiFace)
{
//Decompress the texture data.
PVRTDecompressPVRTC(pTempCompData,bIs2bppPVRTC?1:0,uiMIPWidth,uiMIPHeight,pTempDecompData);
//Move forward through the pointers.
pTempDecompData+=decompressedFaceOffset;
pTempCompData+=compressedFaceOffset;
}
//Work out the current MIP dimensions.
uiMIPWidth=PVRT_MAX(1,uiMIPWidth>>1);
uiMIPHeight=PVRT_MAX(1,uiMIPHeight>>1);
}
}
}
else
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer error: PVRTC not supported.\n");
return PVR_FAIL;
}
}
}
#ifndef TARGET_OS_IPHONE //TODO
else if (eTextureInternalFormat==GL_ETC1_RGB8_OES)
{
if(bIsETCSupported)
{
bIsCompressedFormatSupported = bIsCompressedFormat = true;
}
else
{
if(bAllowDecompress)
{
//Output a warning.
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer warning: ETC not supported. Converting to RGBA8888 instead.\n");
//Modify boolean values.
bIsCompressedFormatSupported = false;
bIsCompressedFormat = true;
//Change texture format.
eTextureFormat = eTextureInternalFormat = GL_RGBA;
eTextureType = GL_UNSIGNED_BYTE;
//Create a near-identical texture header for the decompressed header.
sTextureHeaderDecomp = sTextureHeader;
sTextureHeaderDecomp.u32ChannelType=ePVRTVarTypeUnsignedByteNorm;
sTextureHeaderDecomp.u32ColourSpace=ePVRTCSpacelRGB;
sTextureHeaderDecomp.u64PixelFormat=PVRTGENPIXELID4('r','g','b','a',8,8,8,8);
//Allocate enough memory for the decompressed data. OGLES1, so only decompress one surface/face.
pDecompressedData = malloc(PVRTGetTextureDataSize(sTextureHeaderDecomp, PVRTEX_ALLMIPLEVELS, false, true) );
//Check the malloc.
if (!pDecompressedData)
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer error: Unable to allocate memory to decompress texture.\n");
return PVR_FAIL;
}
//Get the dimensions for the current MIP level.
PVRTuint32 uiMIPWidth = sTextureHeaderDecomp.u32Width>>nLoadFromLevel;
PVRTuint32 uiMIPHeight = sTextureHeaderDecomp.u32Height>>nLoadFromLevel;
//Setup temporary variables.
PVRTuint8* pTempDecompData = (PVRTuint8*)pDecompressedData;
PVRTuint8* pTempCompData = (PVRTuint8*)pTextureData;
if (bIsLegacyPVR)
{
//Decompress all the MIP levels.
for (PVRTuint32 uiFace=0;uiFace<sTextureHeader.u32NumFaces;++uiFace)
{
for (PVRTuint32 uiMIPMap=nLoadFromLevel;uiMIPMap<sTextureHeader.u32MIPMapCount;++uiMIPMap)
{
//Get the face offset. Varies per MIP level.
PVRTuint32 decompressedFaceOffset = PVRTGetTextureDataSize(sTextureHeaderDecomp, uiMIPMap, false, false);
PVRTuint32 compressedFaceOffset = PVRTGetTextureDataSize(sTextureHeader, uiMIPMap, false, false);
//Decompress the texture data.
PVRTDecompressETC(pTempCompData,uiMIPWidth,uiMIPHeight,pTempDecompData,0);
//Move forward through the pointers.
pTempDecompData+=decompressedFaceOffset;
pTempCompData+=compressedFaceOffset;
//Work out the current MIP dimensions.
uiMIPWidth=PVRT_MAX(1,uiMIPWidth>>1);
uiMIPHeight=PVRT_MAX(1,uiMIPHeight>>1);
}
//Reset the dims.
uiMIPWidth=sTextureHeader.u32Width;
uiMIPHeight=sTextureHeader.u32Height;
}
}
else
{
//Decompress all the MIP levels.
for (PVRTuint32 uiMIPMap=nLoadFromLevel;uiMIPMap<sTextureHeader.u32MIPMapCount;++uiMIPMap)
{
//Get the face offset. Varies per MIP level.
PVRTuint32 decompressedFaceOffset = PVRTGetTextureDataSize(sTextureHeaderDecomp, uiMIPMap, false, false);
PVRTuint32 compressedFaceOffset = PVRTGetTextureDataSize(sTextureHeader, uiMIPMap, false, false);
for (PVRTuint32 uiFace=0;uiFace<sTextureHeader.u32NumFaces;++uiFace)
{
//Decompress the texture data.
PVRTDecompressETC(pTempCompData,uiMIPWidth,uiMIPHeight,pTempDecompData,0);
//Move forward through the pointers.
pTempDecompData+=decompressedFaceOffset;
pTempCompData+=compressedFaceOffset;
}
//Work out the current MIP dimensions.
uiMIPWidth=PVRT_MAX(1,uiMIPWidth>>1);
uiMIPHeight=PVRT_MAX(1,uiMIPHeight>>1);
}
}
}
else
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer error: ETC not supported.\n");
return PVR_FAIL;
}
}
}
#endif
}
//Check for BGRA support.
if(eTextureFormat==GL_BGRA_IMG)
{
#ifdef TARGET_OS_IPHONE
eTextureInternalFormat = GL_RGBA;
#endif
if(!bIsBGRA8888Supported)
{
#ifdef TARGET_OS_IPHONE
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: Unable to load GL_BGRA_IMG texture as extension GL_APPLE_texture_format_BGRA8888 is unsupported.\n");
#else
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: Unable to load GL_BGRA_IMG texture as extension GL_IMG_texture_format_BGRA8888 is unsupported.\n");
#endif
return PVR_FAIL;
}
}
//Deal with unsupported texture formats
if (eTextureInternalFormat==0)
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: pixel type not supported.\n");
return PVR_FAIL;
}
//PVR files are never row aligned.
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
//Generate a texture
glGenTextures(1, texName);
//Initialise a texture target.
GLint eTarget=GL_TEXTURE_2D;
//A mix of arrays/cubes/depths are not permitted in OpenGL ES. Check.
if (sTextureHeader.u32NumFaces>1 || sTextureHeader.u32NumSurfaces>1 || sTextureHeader.u32Depth>1)
{
if((sTextureHeader.u32NumFaces>1) && (sTextureHeader.u32NumSurfaces>1))
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: Arrays of cubemaps are not supported by OpenGL ES 3.0\n");
return PVR_FAIL;
}
else if ((sTextureHeader.u32NumFaces>1) && (sTextureHeader.u32Depth>1))
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: 3D Cubemap textures are not supported by OpenGL ES 3.0\n");
return PVR_FAIL;
}
else if ((sTextureHeader.u32NumSurfaces>1) && (sTextureHeader.u32Depth>1))
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: Arrays of 3D textures are not supported by OpenGL ES 3.0\n");
return PVR_FAIL;
}
if(sTextureHeader.u32NumSurfaces>1)
{
eTarget=GL_TEXTURE_2D_ARRAY;
bUsesTexImage3D=true;
}
else if(sTextureHeader.u32NumFaces>1)
{
eTarget=GL_TEXTURE_CUBE_MAP;
}
else if (sTextureHeader.u32Depth>1)
{
eTarget=GL_TEXTURE_3D;
bUsesTexImage3D=true;
}
}
//Bind the texture
glBindTexture(eTarget, *texName);
if(glGetError())
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: glBindTexture() failed.\n");
return PVR_FAIL;
}
//Temporary data to save on if statements within the load loops.
PVRTuint8* pTempData=NULL;
PVRTextureHeaderV3 *psTempHeader=NULL;
if (bIsCompressedFormat && !bIsCompressedFormatSupported)
{
pTempData=(PVRTuint8*)pDecompressedData;
psTempHeader=&sTextureHeaderDecomp;
}
else
{
pTempData=pTextureData;
psTempHeader=&sTextureHeader;
}
//Initialise the current MIP size.
PVRTuint32 uiCurrentMIPSize=0;
//Initialise the width/height
PVRTuint32 u32MIPWidth = sTextureHeader.u32Width;
PVRTuint32 u32MIPHeight = sTextureHeader.u32Height;
PVRTuint32 u32MIPDepth;
if (psTempHeader->u32Depth>1)
{
u32MIPDepth=psTempHeader->u32Depth; //3d texture.
}
else
{
u32MIPDepth=psTempHeader->u32NumSurfaces; //2d arrays.
}
//Loop through all MIP levels.
if (bIsLegacyPVR)
{
//Temporary texture target.
GLint eTextureTarget=eTarget;
//Cubemaps are special.
if (eTextureTarget==GL_TEXTURE_CUBE_MAP)
{
eTextureTarget=GL_TEXTURE_CUBE_MAP_POSITIVE_X;
}
//Loop through all the faces.
for (PVRTuint32 uiFace=0; uiFace<psTempHeader->u32NumFaces; ++uiFace)
{
//Loop through all the mip levels.
for (PVRTuint32 uiMIPLevel=0; uiMIPLevel<psTempHeader->u32MIPMapCount; ++uiMIPLevel)
{
//Get the current MIP size.
uiCurrentMIPSize=PVRTGetTextureDataSize(*psTempHeader,uiMIPLevel,false,false);
if (uiMIPLevel>=nLoadFromLevel)
{
//Upload the texture
if (bUsesTexImage3D)
{
if (bIsCompressedFormat && bIsCompressedFormatSupported)
{
glCompressedTexImage3D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat,u32MIPWidth, u32MIPHeight, u32MIPDepth, 0, uiCurrentMIPSize, pTempData);
}
else
{
glTexImage3D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat, u32MIPWidth, u32MIPHeight, u32MIPDepth, 0, eTextureFormat, eTextureType, pTempData);
}
}
else
{
if (bIsCompressedFormat && bIsCompressedFormatSupported)
{
glCompressedTexImage2D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat,u32MIPWidth, u32MIPHeight, 0, uiCurrentMIPSize, pTempData);
}
else
{
glTexImage2D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat, u32MIPWidth, u32MIPHeight, 0, eTextureFormat, eTextureType, pTempData);
}
}
}
pTempData+=uiCurrentMIPSize;
//Reduce the MIP Size.
u32MIPWidth=PVRT_MAX(1,u32MIPWidth>>1);
u32MIPHeight=PVRT_MAX(1,u32MIPHeight>>1);
if (psTempHeader->u32Depth>1)
{
u32MIPDepth=PVRT_MAX(1,u32MIPDepth>>1);
}
}
//Increase the texture target.
eTextureTarget++;
//Reset the current MIP dimensions.
u32MIPWidth=psTempHeader->u32Width;
u32MIPHeight=psTempHeader->u32Height;
if (psTempHeader->u32Depth>1)
{
u32MIPDepth=psTempHeader->u32Depth;
}
else
{
u32MIPDepth=psTempHeader->u32NumSurfaces; //2d arrays.
}
//Error check
if(glGetError())
{
FREE(pDecompressedData);
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: glTexImage2D() failed.\n");
return PVR_FAIL;
}
}
}
else
{
for (PVRTuint32 uiMIPLevel=0; uiMIPLevel<psTempHeader->u32MIPMapCount; ++uiMIPLevel)
{
//Get the current MIP size.
uiCurrentMIPSize=PVRTGetTextureDataSize(*psTempHeader,uiMIPLevel,false,false);
GLint eTextureTarget=eTarget;
//Cubemaps are special.
if (eTextureTarget==GL_TEXTURE_CUBE_MAP)
{
eTextureTarget=GL_TEXTURE_CUBE_MAP_POSITIVE_X;
}
for (PVRTuint32 uiFace=0; uiFace<psTempHeader->u32NumFaces; ++uiFace)
{
if (uiMIPLevel>=nLoadFromLevel)
{
//Upload the texture
if (bUsesTexImage3D)
{
//Upload the texture
if (bIsCompressedFormat && bIsCompressedFormatSupported)
{
glCompressedTexImage3D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat,u32MIPWidth, u32MIPHeight, u32MIPDepth, 0, uiCurrentMIPSize, pTempData);
}
else
{
glTexImage3D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat, u32MIPWidth, u32MIPHeight, u32MIPDepth, 0, eTextureFormat, eTextureType, pTempData);
}
}
else
{
//Upload the texture
if (bIsCompressedFormat && bIsCompressedFormatSupported)
{
glCompressedTexImage2D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat,u32MIPWidth, u32MIPHeight, 0, uiCurrentMIPSize, pTempData);
}
else
{
glTexImage2D(eTextureTarget,uiMIPLevel-nLoadFromLevel,eTextureInternalFormat, u32MIPWidth, u32MIPHeight, 0, eTextureFormat, eTextureType, pTempData);
}
}
}
pTempData+=uiCurrentMIPSize;
eTextureTarget++;
}
//Reduce the MIP Size.
u32MIPWidth=PVRT_MAX(1,u32MIPWidth>>1);
u32MIPHeight=PVRT_MAX(1,u32MIPHeight>>1);
if (psTempHeader->u32Depth>1)
{
u32MIPDepth=PVRT_MAX(1,u32MIPDepth>>1); //Only reduce depth for 3D textures, not texture arrays.
}
//Error check
if(glGetError())
{
FREE(pDecompressedData);
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: glTexImage2D() failed.\n");
return PVR_FAIL;
}
}
}
FREE(pDecompressedData);
//Error check
if(glGetError())
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: glTexImage2D() failed.\n");
return PVR_FAIL;
}
//Set Minification and Magnification filters according to whether MIP maps are present.
if(eTextureType==GL_FLOAT || eTextureType==GL_HALF_FLOAT)
{
if(sTextureHeader.u32MIPMapCount==1)
{ // Texture filter modes are limited to these for float textures
glTexParameteri(eTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(eTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
else
{
glTexParameteri(eTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(eTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
}
else
{
if(sTextureHeader.u32MIPMapCount==1)
{
glTexParameteri(eTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(eTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else
{
glTexParameteri(eTarget, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
glTexParameteri(eTarget, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
}
if( (sTextureHeader.u32Width & (sTextureHeader.u32Width - 1)) | (sTextureHeader.u32Height & (sTextureHeader.u32Height - 1)))
{
/*
NPOT textures requires the wrap mode to be set explicitly to
GL_CLAMP_TO_EDGE or the texture will be inconsistent.
*/
glTexParameteri(eTarget, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(eTarget, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
else
{
glTexParameteri(eTarget, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(eTarget, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
//Error check
if(glGetError())
{
PVRTErrorOutputDebug("PVRTTextureLoadFromPointer failed: glTexParameter() failed.\n");
return PVR_FAIL;
}
return PVR_SUCCESS;
}
/*!***************************************************************************
@Function PVRTTextureLoadFromPVR
@Input filename Filename of the .PVR file to load the texture from
@Modified texName the OpenGL ES texture name as returned by glBindTexture
@Modified psTextureHeader Pointer to a PVR_Texture_Header struct. Modified to
contain the header data of the returned texture Ignored if NULL.
@Input bAllowDecompress Allow decompression if PVRTC is not supported in hardware.
@Input nLoadFromLevel Which mipmap level to start loading from (0=all)
@Modified pMetaData If a valid map is supplied, this will return any and all
MetaDataBlocks stored in the texture, organised by DevFourCC
then identifier. Supplying NULL will ignore all MetaData.
@Return PVR_SUCCESS on success
@Description Allows textures to be stored in binary PVR files and loaded in. Can load parts of a
mipmaped texture (ie skipping the highest detailed levels).
Sets the texture MIN/MAG filter to GL_LINEAR_MIPMAP_NEAREST/GL_LINEAR
if mipmaps are present, GL_LINEAR/GL_LINEAR otherwise.
*****************************************************************************/
EPVRTError PVRTTextureLoadFromPVR( const char * const filename,
GLuint * const texName,
const void *psTextureHeader,
bool bAllowDecompress,
const unsigned int nLoadFromLevel,
CPVRTMap<unsigned int, CPVRTMap<unsigned int, MetaDataBlock> > *pMetaData)
{
//Attempt to open file.
CPVRTResourceFile TexFile(filename);
//Check file opened successfully.
if (!TexFile.IsOpen())
{
return PVR_FAIL;
}
//Header size.
PVRTuint32 u32HeaderSize=0;
//Boolean whether to byte swap the texture data or not.
bool bSwapDataEndianness=false;
//Texture header to check against.
PVRTextureHeaderV3 sTextureHeader;
//The channel type for endian swapping.
EPVRTVariableType u32CurrentChannelType=ePVRTVarTypeUnsignedByte;
//Check the first word of the file and see if it's equal to the current identifier (or reverse identifier)
if(*(PVRTuint32*)TexFile.DataPtr()!=PVRTEX_CURR_IDENT && *(PVRTuint32*)TexFile.DataPtr()!=PVRTEX_CURR_IDENT_REV)
{
//Swap the header bytes if necessary.
if(!PVRTIsLittleEndian())
{
bSwapDataEndianness=true;
PVRTuint32 u32HeaderSize=PVRTByteSwap32(*(PVRTuint32*)TexFile.DataPtr());
for (PVRTuint32 i=0; i<u32HeaderSize; ++i)
{
PVRTByteSwap( (PVRTuint8*)( ( (PVRTuint32*)TexFile.DataPtr() )+i),sizeof(PVRTuint32) );
}
}
//Get a pointer to the header.
PVR_Texture_Header* sLegacyTextureHeader=(PVR_Texture_Header*)TexFile.DataPtr();
//Set the header size.
u32HeaderSize=sLegacyTextureHeader->dwHeaderSize;
//We only really need the channel type.
PVRTuint64 tempFormat;
EPVRTColourSpace tempColourSpace;
bool tempIsPreMult;
//Map the enum to get the channel type.
PVRTMapLegacyTextureEnumToNewFormat( (PVRTPixelType)( sLegacyTextureHeader->dwpfFlags&0xff),tempFormat,tempColourSpace, u32CurrentChannelType, tempIsPreMult);
}
// If the header file has a reverse identifier, then we need to swap endianness
else if(*(PVRTuint32*)TexFile.DataPtr()==PVRTEX_CURR_IDENT_REV)
{
//Setup the texture header
sTextureHeader=*(PVRTextureHeaderV3*)TexFile.DataPtr();
bSwapDataEndianness=true;
PVRTextureHeaderV3* pTextureHeader=(PVRTextureHeaderV3*)TexFile.DataPtr();
pTextureHeader->u32ChannelType=PVRTByteSwap32(pTextureHeader->u32ChannelType);
pTextureHeader->u32ColourSpace=PVRTByteSwap32(pTextureHeader->u32ColourSpace);
pTextureHeader->u32Depth=PVRTByteSwap32(pTextureHeader->u32Depth);
pTextureHeader->u32Flags=PVRTByteSwap32(pTextureHeader->u32Flags);
pTextureHeader->u32Height=PVRTByteSwap32(pTextureHeader->u32Height);
pTextureHeader->u32MetaDataSize=PVRTByteSwap32(pTextureHeader->u32MetaDataSize);
pTextureHeader->u32MIPMapCount=PVRTByteSwap32(pTextureHeader->u32MIPMapCount);
pTextureHeader->u32NumFaces=PVRTByteSwap32(pTextureHeader->u32NumFaces);
pTextureHeader->u32NumSurfaces=PVRTByteSwap32(pTextureHeader->u32NumSurfaces);
pTextureHeader->u32Version=PVRTByteSwap32(pTextureHeader->u32Version);
pTextureHeader->u32Width=PVRTByteSwap32(pTextureHeader->u32Width);
PVRTByteSwap((PVRTuint8*)&pTextureHeader->u64PixelFormat,sizeof(PVRTuint64));
//Channel type.
u32CurrentChannelType=(EPVRTVariableType)pTextureHeader->u32ChannelType;
//Header size.
u32HeaderSize=PVRTEX3_HEADERSIZE+sTextureHeader.u32MetaDataSize;
}
else
{
//Header size.
u32HeaderSize=PVRTEX3_HEADERSIZE+sTextureHeader.u32MetaDataSize;
}
// Convert the data if needed
if(bSwapDataEndianness)
{
//Get the size of the variables types.
PVRTuint32 ui32VariableSize=0;
switch(u32CurrentChannelType)
{
case ePVRTVarTypeFloat:
case ePVRTVarTypeUnsignedInteger:
case ePVRTVarTypeUnsignedIntegerNorm:
case ePVRTVarTypeSignedInteger:
case ePVRTVarTypeSignedIntegerNorm:
{
ui32VariableSize=4;
break;
}
case ePVRTVarTypeUnsignedShort:
case ePVRTVarTypeUnsignedShortNorm:
case ePVRTVarTypeSignedShort:
case ePVRTVarTypeSignedShortNorm:
{
ui32VariableSize=2;
break;
}
case ePVRTVarTypeUnsignedByte:
case ePVRTVarTypeUnsignedByteNorm:
case ePVRTVarTypeSignedByte:
case ePVRTVarTypeSignedByteNorm:
{
ui32VariableSize=1;
break;
}
default:
return PVR_FAIL;
}
//If the size of the variable type is greater than 1, then we need to byte swap.
if (ui32VariableSize>1)
{
//Get the texture data.
PVRTuint8* pu8OrigData = ( (PVRTuint8*)TexFile.DataPtr() + u32HeaderSize);
//Get the size of the texture data.
PVRTuint32 ui32TextureDataSize = PVRTGetTextureDataSize(sTextureHeader);
//Loop through and byte swap all the data. It's swapped in place so no need to do anything special.
for(PVRTuint32 i = 0; i < ui32TextureDataSize; i+=ui32VariableSize)
{
PVRTByteSwap(pu8OrigData+i,ui32VariableSize);
}
}
}
return PVRTTextureLoadFromPointer(TexFile.DataPtr(), texName, psTextureHeader, bAllowDecompress, nLoadFromLevel,NULL,pMetaData);
}
/*****************************************************************************
End of file (PVRTTextureAPI.cpp)
*****************************************************************************/
/*!****************************************************************************
@file OGLES3/PVRTTextureAPI.h
@ingroup API_OGLES3
@copyright Copyright (c) Imagination Technologies Limited.
@brief OGLES3 texture loading.
******************************************************************************/
#ifndef _PVRTTEXTUREAPI_H_
#define _PVRTTEXTUREAPI_H_
/*!
@addtogroup API_OGLES3
@{
*/
#include "../PVRTError.h"
/****************************************************************************
** Functions
****************************************************************************/
template <typename KeyType, typename DataType>
class CPVRTMap;
/*!***************************************************************************
@brief Allows textures to be stored in C header files and loaded in. Can load parts of a
mipmaped texture (ie skipping the highest detailed levels).
Sets the texture MIN/MAG filter to GL_LINEAR_MIPMAP_NEAREST/GL_LINEAR
if mipmaps are present, GL_LINEAR/GL_LINEAR otherwise.
@param[in] pointer Pointer to header-texture's structure
@param[in,out] texName the OpenGL ES texture name as returned by glBindTexture
@param[in,out] psTextureHeader Pointer to a PVRTextureHeaderV3 struct. Modified to
contain the header data of the returned texture Ignored if NULL.
@param[in] bAllowDecompress Allow decompression if PVRTC is not supported in hardware.
@param[in] nLoadFromLevel Which mipmap level to start loading from (0=all)
@param[in] texPtr If null, texture follows header, else texture is here.
@param[in,out] pMetaData If a valid map is supplied, this will return any and all
MetaDataBlocks stored in the texture, organised by DevFourCC
then identifier. Supplying NULL will ignore all MetaData.
@return PVR_SUCCESS on success
*****************************************************************************/
EPVRTError PVRTTextureLoadFromPointer( const void* pointer,
GLuint *const texName,
const void *psTextureHeader=NULL,
bool bAllowDecompress = true,
const unsigned int nLoadFromLevel=0,
const void * const texPtr=0,
CPVRTMap<unsigned int, CPVRTMap<unsigned int, struct MetaDataBlock> > *pMetaData=NULL);
/*!***************************************************************************
@brief Allows textures to be stored in binary PVR files and loaded in. Can load parts of a
mipmaped texture (ie skipping the highest detailed levels).
Sets the texture MIN/MAG filter to GL_LINEAR_MIPMAP_NEAREST/GL_LINEAR
if mipmaps are present, GL_LINEAR/GL_LINEAR otherwise.
@param[in] filename Filename of the .PVR file to load the texture from
@param[in,out] texName the OpenGL ES texture name as returned by glBindTexture
@param[in,out] psTextureHeader Pointer to a PVRTextureHeaderV3 struct. Modified to
contain the header data of the returned texture Ignored if NULL.
@param[in] bAllowDecompress Allow decompression if PVRTC is not supported in hardware.
@param[in] nLoadFromLevel Which mipmap level to start loading from (0=all)
@param[in,out] pMetaData If a valid map is supplied, this will return any and all
MetaDataBlocks stored in the texture, organised by DevFourCC
then identifier. Supplying NULL will ignore all MetaData.
@return PVR_SUCCESS on success
*****************************************************************************/
EPVRTError PVRTTextureLoadFromPVR( const char * const filename,
GLuint * const texName,
const void *psTextureHeader=NULL,
bool bAllowDecompress = true,
const unsigned int nLoadFromLevel=0,
CPVRTMap<unsigned int, CPVRTMap<unsigned int, struct MetaDataBlock> > *pMetaData=NULL);
/*! @} */
#endif /* _PVRTTEXTUREAPI_H_ */
/*****************************************************************************
End of file (PVRTTextureAPI.h)
*****************************************************************************/
/******************************************************************************
@File OGLES3/PVRTgles3Ext.cpp
@Title OGLES3/PVRTgles3Ext
@Version
@Copyright Copyright (c) Imagination Technologies Limited.
@Platform Independent
@Description OpenGL ES 3.0 extensions
******************************************************************************/
#include <string.h>
#include "PVRTContext.h"
#include "PVRTgles3Ext.h"
/****************************************************************************
** Local code
****************************************************************************/
/****************************************************************************
** Class: CPVRTgles3Ext
****************************************************************************/
/*!***************************************************************************
@Function LoadExtensions
@Description Initialises IMG extensions
*****************************************************************************/
void CPVRTgles3Ext::LoadExtensions()
{
glRenderbufferStorageMultisampleIMG = 0;
glFramebufferTexture2DMultisampleIMG = 0;
glRenderbufferStorageMultisampleEXT = 0;
glFramebufferTexture2DMultisampleEXT = 0;
// Supported extensions provide new entry points for OpenGL ES 3.0.
const GLubyte *pszGLExtensions;
/* Retrieve GL extension string */
pszGLExtensions = glGetString(GL_EXTENSIONS);
#if !defined(TARGET_OS_IPHONE)
/* GL_IMG_multisampled_render_to_texture */
if (strstr((char *)pszGLExtensions, "GL_IMG_multisampled_render_to_texture"))
{
glRenderbufferStorageMultisampleIMG = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) PVRGetProcAddress(glRenderbufferStorageMultisampleIMG);
glFramebufferTexture2DMultisampleIMG = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) PVRGetProcAddress(glFramebufferTexture2DMultisampleIMG);
}
/* GL_EXT_multisampled_render_to_texture */
if (strstr((char *)pszGLExtensions, "GL_EXT_multisampled_render_to_texture"))
{
glRenderbufferStorageMultisampleEXT = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT) PVRGetProcAddress(glRenderbufferStorageMultisampleEXT);
glFramebufferTexture2DMultisampleEXT = (PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT) PVRGetProcAddress(glFramebufferTexture2DMultisampleEXT);
}
#endif
}
/*!***********************************************************************
@Function IsGLExtensionSupported
@Input extension extension to query for
@Returns True if the extension is supported
@Description Queries for support of an extension
*************************************************************************/
bool CPVRTgles3Ext::IsGLExtensionSupported(const char * const extension)
{
// The recommended technique for querying OpenGL extensions;
// from http://opengl.org/resources/features/OGLextensions/
const GLubyte *extensions = NULL;
const GLubyte *start;
GLubyte *where, *terminator;
/* Extension names should not have spaces. */
where = (GLubyte *) strchr(extension, ' ');
if (where || *extension == '\0')
return 0;
extensions = glGetString(GL_EXTENSIONS);
/* It takes a bit of care to be fool-proof about parsing the
OpenGL extensions string. Don't be fooled by sub-strings, etc. */
start = extensions;
for (;;) {
where = (GLubyte *) strstr((const char *) start, extension);
if (!where)
break;
terminator = where + strlen(extension);
if (where == start || *(where - 1) == ' ')
if (*terminator == ' ' || *terminator == '\0')
return true;
start = terminator;
}
return false;
}
/*****************************************************************************
End of file (PVRTglesExt.cpp)
*****************************************************************************/
/*!****************************************************************************
@file OGLES3/PVRTgles3Ext.h
@ingroup API_OGLES3
@copyright Copyright (c) Imagination Technologies Limited.
@brief OpenGL ES 3.0 extensions
******************************************************************************/
#ifndef _PVRTgles3Ext_H_
#define _PVRTgles3Ext_H_
/*!
@addtogroup API_OGLES3
@{
*/
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE==1
#import <OpenGLES/ES3/gl.h>
#import <OpenGLES/ES3/glext.h>
// No binary shaders are allowed on the iphone and so this value is not defined
// Defining here allows for a more graceful fail of binary shader loading at runtime
// which can be recovered from instead of fail at compile time
#define GL_SGX_BINARY_IMG 0
#else
#ifdef BUILD_OGLES31
#include <GLES3/gl31.h>
#else
#include <GLES3/gl3.h>
#endif
#endif
#if !defined(EGL_NOT_PRESENT)
#define PVRGetProcAddress(x) eglGetProcAddress(#x)
#endif
/****************************************************************************
** Build options
****************************************************************************/
#define GL_PVRTGLESEXT_VERSION 3
/**************************************************************************
****************************** GL EXTENSIONS ******************************
**************************************************************************/
/*!**************************************************************************
@class CPVRTgles3Ext
@brief A class for initialising and managing OGLES3 extensions
****************************************************************************/
class CPVRTgles3Ext
{
public:
// typedef definition for pointers to functions returned by eglGetProcAddress
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT)(GLenum, GLenum, GLenum, GLuint,GLint, GLsizei);
typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG)(GLenum, GLsizei, GLenum, GLsizei, GLsizei);
typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG)(GLenum, GLenum, GLenum, GLuint,GLint, GLsizei);
// GL_IMG_multisampled_render_to_texture
#if !defined(GL_IMG_multisampled_render_to_texture)
#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134
#define GL_MAX_SAMPLES_IMG 0x9135
#define GL_TEXTURE_SAMPLES_IMG 0x9136
#endif
// GL_EXT_multisampled_render_to_texture
#if !defined(GL_EXT_multisampled_render_to_texture)
#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C
#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
#define GL_MAX_SAMPLES_EXT 0x8D57
#endif
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXT glRenderbufferStorageMultisampleEXT;
PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG glRenderbufferStorageMultisampleIMG;
PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXT glFramebufferTexture2DMultisampleEXT;
PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG glFramebufferTexture2DMultisampleIMG;
/*!***********************************************************************
@brief Initialises IMG extensions
*************************************************************************/
void LoadExtensions();
/*!***********************************************************************
@brief Queries for support of an extension
@param[in] extension Extension to query for
@return True if the extension is supported
*************************************************************************/
static bool IsGLExtensionSupported(const char * const extension);
};
/*! @} */
#endif /* _PVRTgles3Ext_H_ */
/*****************************************************************************
End of file (PVRTgles3Ext.h)
*****************************************************************************/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment