зеркало из https://github.com/AvaloniaUI/angle.git
Port the MultipleRenderTarget sample to the new sample framework.
Renamed to MultipleDrawBuffers and added shader loading from file. BUG=angle:521 Change-Id: Iffeb589a95eee4409d3624c56fe3a5e4a7d5be63 Reviewed-on: https://chromium-review.googlesource.com/188724 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Родитель
8dd592bf2a
Коммит
712e3f4d65
|
@ -173,6 +173,10 @@
|
|||
<Project>{130A534E-6BA3-DB9C-B0D2-5ACE5CCB2632}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\samples\multiple_draw_buffers.vcxproj">
|
||||
<Project>{58BE89D7-25D5-CC84-EDBF-412C12C59709}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\samples\simple_texture_2d.vcxproj">
|
||||
<Project>{0BD6333E-E82C-7665-C386-CDA40096413D}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
|
|
|
@ -18,6 +18,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "All", "All.vcxproj", "{D048
|
|||
{37E1BB43-65DC-A25A-042E-30B88E6C75A2} = {37E1BB43-65DC-A25A-042E-30B88E6C75A2}
|
||||
{8C20B90A-FBCB-B63F-435A-3299A1C38B2C} = {8C20B90A-FBCB-B63F-435A-3299A1C38B2C}
|
||||
{130A534E-6BA3-DB9C-B0D2-5ACE5CCB2632} = {130A534E-6BA3-DB9C-B0D2-5ACE5CCB2632}
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709} = {58BE89D7-25D5-CC84-EDBF-412C12C59709}
|
||||
{0BD6333E-E82C-7665-C386-CDA40096413D} = {0BD6333E-E82C-7665-C386-CDA40096413D}
|
||||
{93B7F18A-947E-69A1-9CD8-D1E5144E792A} = {93B7F18A-947E-69A1-9CD8-D1E5144E792A}
|
||||
{459E5678-892C-4EF9-6ED8-0D9E5272B4FF} = {459E5678-892C-4EF9-6ED8-0D9E5272B4FF}
|
||||
|
@ -85,6 +86,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_texture", "..\samples
|
|||
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81} = {7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multiple_draw_buffers", "..\samples\multiple_draw_buffers.vcxproj", "{58BE89D7-25D5-CC84-EDBF-412C12C59709}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{297C46B0-9263-A9EA-82B1-EA221E7D7C7F} = {297C46B0-9263-A9EA-82B1-EA221E7D7C7F}
|
||||
{FBAEE4F6-562A-588F-01F9-72DCABB3B061} = {FBAEE4F6-562A-588F-01F9-72DCABB3B061}
|
||||
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81} = {7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "particle_system", "..\samples\particle_system.vcxproj", "{8C20B90A-FBCB-B63F-435A-3299A1C38B2C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{297C46B0-9263-A9EA-82B1-EA221E7D7C7F} = {297C46B0-9263-A9EA-82B1-EA221E7D7C7F}
|
||||
|
@ -201,6 +209,10 @@ Global
|
|||
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.Build.0 = Release|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Release|Win32.Build.0 = Release|Win32
|
||||
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Release|Win32.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.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="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{58BE89D7-25D5-CC84-EDBF-412C12C59709}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>multiple_draw_buffers</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props"/>
|
||||
<PropertyGroup Label="Configuration">
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props"/>
|
||||
<ImportGroup Label="ExtensionSettings"/>
|
||||
<ImportGroup Label="PropertySheets">
|
||||
<Import Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"/>
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros"/>
|
||||
<PropertyGroup>
|
||||
<ExecutablePath>$(ExecutablePath);$(MSBuildProjectDirectory)\..\..\third_party\cygwin\bin\;$(MSBuildProjectDirectory)\..\..\third_party\python_26\</ExecutablePath>
|
||||
<OutDir>$(SolutionDir)$(Configuration)_$(Platform)\</OutDir>
|
||||
<IntDir>$(OutDir)obj\$(ProjectName)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<TargetName>$(ProjectName)</TargetName>
|
||||
<TargetPath>$(OutDir)\$(ProjectName)$(TargetExt)</TargetPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\include;..\..\samples\angle\sample_util;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4201;4100;4127;4189;4239;4244;4245;4512;4702;4530;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;_HAS_EXCEPTIONS=0;_WIN32_WINNT=0x0600;_WINDOWS;NOMINMAX;WIN32;WIN32_LEAN_AND_MEAN;WINVER=0x0600;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
<Link>
|
||||
<AdditionalDependencies>kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ImportLibrary>$(OutDir)lib\$(TargetName).lib</ImportLibrary>
|
||||
<MapFileName>$(OutDir)$(TargetName).map</MapFileName>
|
||||
<OutputFile>$(OutDir)$(ProjectName)$(TargetExt)</OutputFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>..\..\include;..\..\samples\angle\sample_util;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>..\..\include;..\..\samples\angle\sample_util;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
|
||||
<BufferSecurityCheck>true</BufferSecurityCheck>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
<DisableSpecificWarnings>4201;4100;4127;4189;4239;4244;4245;4512;4702;4530;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;_HAS_EXCEPTIONS=0;_WIN32_WINNT=0x0600;_WINDOWS;NOMINMAX;WIN32;WIN32_LEAN_AND_MEAN;WINVER=0x0600;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<RuntimeTypeInfo>false</RuntimeTypeInfo>
|
||||
<TreatWarningAsError>true</TreatWarningAsError>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
</ClCompile>
|
||||
<Lib>
|
||||
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Lib>
|
||||
<Link>
|
||||
<AdditionalDependencies>kernel32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;user32.lib;uuid.lib;odbc32.lib;odbccp32.lib;delayimp.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>C:/Program Files (x86)/Windows Kits/8.0/Lib/win8/um/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<FixedBaseAddress>false</FixedBaseAddress>
|
||||
<GenerateDebugInformation>false</GenerateDebugInformation>
|
||||
<ImportLibrary>$(OutDir)lib\$(TargetName).lib</ImportLibrary>
|
||||
<MapFileName>$(OutDir)$(TargetName).map</MapFileName>
|
||||
<OutputFile>$(OutDir)$(ProjectName)$(TargetExt)</OutputFile>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
<ResourceCompile>
|
||||
<AdditionalIncludeDirectories>..\..\include;..\..\samples\angle\sample_util;C:\Program Files (x86)\Windows Kits\8.0\Include\shared;C:\Program Files (x86)\Windows Kits\8.0\Include\um;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\samples\samples.gyp"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\samples\angle\multiple_draw_buffers\MultipleDrawBuffers.cpp"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_vs.glsl">
|
||||
<FileType>Document</FileType>
|
||||
<Command>call mkdir "$(OutDir)" 2>nul & set ERRORLEVEL=0 & copy /Y "..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_vs.glsl" "$(OutDir)multiple_draw_buffers_vs.glsl"</Command>
|
||||
<Message>Copying angle/multiple_draw_buffers/multiple_draw_buffers_vs.glsl to $(OutDir)\multiple_draw_buffers_vs.glsl</Message>
|
||||
<Outputs>$(OutDir)\multiple_draw_buffers_vs.glsl</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_copy_fs.glsl">
|
||||
<FileType>Document</FileType>
|
||||
<Command>call mkdir "$(OutDir)" 2>nul & set ERRORLEVEL=0 & copy /Y "..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_copy_fs.glsl" "$(OutDir)multiple_draw_buffers_copy_fs.glsl"</Command>
|
||||
<Message>Copying angle/multiple_draw_buffers/multiple_draw_buffers_copy_fs.glsl to $(OutDir)\multiple_draw_buffers_copy_fs.glsl</Message>
|
||||
<Outputs>$(OutDir)\multiple_draw_buffers_copy_fs.glsl</Outputs>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_fs.glsl">
|
||||
<FileType>Document</FileType>
|
||||
<Command>call mkdir "$(OutDir)" 2>nul & set ERRORLEVEL=0 & copy /Y "..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_fs.glsl" "$(OutDir)multiple_draw_buffers_fs.glsl"</Command>
|
||||
<Message>Copying angle/multiple_draw_buffers/multiple_draw_buffers_fs.glsl to $(OutDir)\multiple_draw_buffers_fs.glsl</Message>
|
||||
<Outputs>$(OutDir)\multiple_draw_buffers_fs.glsl</Outputs>
|
||||
</CustomBuild>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="sample_util.vcxproj">
|
||||
<Project>{297C46B0-9263-A9EA-82B1-EA221E7D7C7F}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\src\libEGL.vcxproj">
|
||||
<Project>{FBAEE4F6-562A-588F-01F9-72DCABB3B061}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\src\libGLESv2.vcxproj">
|
||||
<Project>{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets"/>
|
||||
<ImportGroup Label="ExtensionTargets"/>
|
||||
</Project>
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="angle">
|
||||
<UniqueIdentifier>{2039F76D-4C9A-B8A0-444A-4766C6F6104A}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="angle\multiple_draw_buffers">
|
||||
<UniqueIdentifier>{D0BAF5AC-C79C-4569-5154-A04FD87C707E}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\samples\samples.gyp"/>
|
||||
<None Include="..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_copy_fs.glsl">
|
||||
<Filter>angle\multiple_draw_buffers</Filter>
|
||||
</None>
|
||||
<None Include="..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_vs.glsl">
|
||||
<Filter>angle\multiple_draw_buffers</Filter>
|
||||
</None>
|
||||
<ClCompile Include="..\..\samples\angle\multiple_draw_buffers\MultipleDrawBuffers.cpp">
|
||||
<Filter>angle\multiple_draw_buffers</Filter>
|
||||
</ClCompile>
|
||||
<None Include="..\..\samples\angle\multiple_draw_buffers\multiple_draw_buffers_fs.glsl">
|
||||
<Filter>angle\multiple_draw_buffers</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -59,6 +59,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_texture", "multi_text
|
|||
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81} = {7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multiple_draw_buffers", "multiple_draw_buffers.vcxproj", "{58BE89D7-25D5-CC84-EDBF-412C12C59709}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{297C46B0-9263-A9EA-82B1-EA221E7D7C7F} = {297C46B0-9263-A9EA-82B1-EA221E7D7C7F}
|
||||
{FBAEE4F6-562A-588F-01F9-72DCABB3B061} = {FBAEE4F6-562A-588F-01F9-72DCABB3B061}
|
||||
{7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81} = {7FBD6F69-B9A4-69F1-A12B-8DACB3F8CD81}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "particle_system", "particle_system.vcxproj", "{8C20B90A-FBCB-B63F-435A-3299A1C38B2C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{297C46B0-9263-A9EA-82B1-EA221E7D7C7F} = {297C46B0-9263-A9EA-82B1-EA221E7D7C7F}
|
||||
|
@ -175,6 +182,10 @@ Global
|
|||
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{46160987-0221-9E14-3B88-80F9FCFCFFBF}.Release|Win32.Build.0 = Release|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{58BE89D7-25D5-CC84-EDBF-412C12C59709}.Release|Win32.Build.0 = Release|Win32
|
||||
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6BC75FF2-C11A-C393-F9BB-BF29FF29D736}.Release|Win32.ActiveCfg = Release|Win32
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
//
|
||||
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
//
|
||||
|
||||
// Based on Simple_Texture2D.c from
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
|
||||
#include "SampleApplication.h"
|
||||
#include "shader_utils.h"
|
||||
#include "path_utils.h"
|
||||
#include "texture_utils.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
class MultipleDrawBuffersSample : public SampleApplication
|
||||
{
|
||||
public:
|
||||
MultipleDrawBuffersSample::MultipleDrawBuffersSample()
|
||||
: SampleApplication("MultipleDrawBuffers", 1280, 720)
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool initialize()
|
||||
{
|
||||
// Check EXT_draw_buffers is supported
|
||||
char *extensionString = (char*)glGetString(GL_EXTENSIONS);
|
||||
if (strstr(extensionString, "GL_EXT_draw_buffers") != NULL)
|
||||
{
|
||||
// Retrieve the address of glDrawBuffersEXT from EGL
|
||||
mDrawBuffers = (PFNGLDRAWBUFFERSEXTPROC)eglGetProcAddress("glDrawBuffersEXT");
|
||||
}
|
||||
else
|
||||
{
|
||||
mDrawBuffers = glDrawBuffers;
|
||||
}
|
||||
|
||||
if (!mDrawBuffers)
|
||||
{
|
||||
std::cerr << "Unable to load glDrawBuffers[EXT] entry point.";
|
||||
return false;
|
||||
}
|
||||
|
||||
mMRTProgram = CompileProgramFromFiles(GetExecutableDirectory() + "/multiple_draw_buffers_vs.glsl",
|
||||
GetExecutableDirectory() + "/multiple_draw_buffers_fs.glsl");
|
||||
if (!mMRTProgram)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
mCopyProgram = CompileProgramFromFiles(GetExecutableDirectory() + "/multiple_draw_buffers_vs.glsl",
|
||||
GetExecutableDirectory() + "/multiple_draw_buffers_copy_fs.glsl");
|
||||
if (!mCopyProgram)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the attribute locations
|
||||
mPositionLoc = glGetAttribLocation(mCopyProgram, "a_position");
|
||||
mTexCoordLoc = glGetAttribLocation(mCopyProgram, "a_texCoord");
|
||||
|
||||
// Get the sampler location
|
||||
mSamplerLoc = glGetUniformLocation(mCopyProgram, "s_texture");
|
||||
|
||||
// Load the texture
|
||||
mTexture = CreateSimpleTexture2D();
|
||||
|
||||
// Initialize the user framebuffer
|
||||
glGenFramebuffers(1, &mFramebuffer);
|
||||
glGenTextures(mFramebufferAttachmentCount, mFramebufferTextures);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
|
||||
for (size_t i = 0; i < mFramebufferAttachmentCount; i++)
|
||||
{
|
||||
// Create textures for the four color attachments
|
||||
glBindTexture(GL_TEXTURE_2D, mFramebufferTextures[i]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getWindow()->getWidth(), getWindow()->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, mFramebufferTextures[i], 0);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void destroy()
|
||||
{
|
||||
glDeleteProgram(mCopyProgram);
|
||||
glDeleteProgram(mMRTProgram);
|
||||
glDeleteTextures(1, &mTexture);
|
||||
glDeleteTextures(mFramebufferAttachmentCount, mFramebufferTextures);
|
||||
glDeleteFramebuffers(1, &mFramebuffer);
|
||||
}
|
||||
|
||||
virtual void draw()
|
||||
{
|
||||
GLfloat vertices[] =
|
||||
{
|
||||
-0.8f, 0.8f, 0.0f, // Position 0
|
||||
0.0f, 0.0f, // TexCoord 0
|
||||
-0.8f, -0.8f, 0.0f, // Position 1
|
||||
0.0f, 1.0f, // TexCoord 1
|
||||
0.8f, -0.8f, 0.0f, // Position 2
|
||||
1.0f, 1.0f, // TexCoord 2
|
||||
0.8f, 0.8f, 0.0f, // Position 3
|
||||
1.0f, 0.0f // TexCoord 3
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
GLenum drawBuffers[mFramebufferAttachmentCount] =
|
||||
{
|
||||
GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_COLOR_ATTACHMENT1_EXT,
|
||||
GL_COLOR_ATTACHMENT2_EXT,
|
||||
GL_COLOR_ATTACHMENT3_EXT
|
||||
};
|
||||
|
||||
// Enable drawing to the four color attachments of the user framebuffer
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
|
||||
mDrawBuffers(mFramebufferAttachmentCount, drawBuffers);
|
||||
|
||||
// Set the viewport
|
||||
size_t width = getWindow()->getWidth();
|
||||
size_t height = getWindow()->getHeight();
|
||||
glViewport(0, 0, width, height);
|
||||
|
||||
// Clear the color buffer
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
// Use the program object
|
||||
glUseProgram(mMRTProgram);
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer(mPositionLoc, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vertices);
|
||||
glEnableVertexAttribArray(mPositionLoc);
|
||||
|
||||
// Load the texture coordinate
|
||||
glVertexAttribPointer(mTexCoordLoc, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), vertices + 3);
|
||||
glEnableVertexAttribArray(mTexCoordLoc);
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, mTexture);
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i(mSamplerLoc, 0);
|
||||
|
||||
// Draw the textured quad to the four render targets
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
|
||||
// Enable the default framebuffer and single textured drawing
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glUseProgram(mCopyProgram);
|
||||
|
||||
// Draw the four textured quads to a separate region in the viewport
|
||||
glBindTexture(GL_TEXTURE_2D, mFramebufferTextures[0]);
|
||||
glViewport(0, 0, width / 2, height / 2);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, mFramebufferTextures[1]);
|
||||
glViewport(width / 2, 0, width / 2, height / 2);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, mFramebufferTextures[2]);
|
||||
glViewport(0, height / 2, width / 2, height / 2);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, mFramebufferTextures[3]);
|
||||
glViewport(width / 2, height / 2, width / 2, height / 2);
|
||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices);
|
||||
}
|
||||
|
||||
private:
|
||||
// Handle to a program object
|
||||
GLuint mMRTProgram;
|
||||
GLuint mCopyProgram;
|
||||
|
||||
// Attribute locations
|
||||
GLint mPositionLoc;
|
||||
GLint mTexCoordLoc;
|
||||
|
||||
// Sampler location
|
||||
GLint mSamplerLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint mTexture;
|
||||
|
||||
// Framebuffer object handle
|
||||
GLuint mFramebuffer;
|
||||
|
||||
// Framebuffer color attachments
|
||||
static const size_t mFramebufferAttachmentCount = 4;
|
||||
GLuint mFramebufferTextures[mFramebufferAttachmentCount];
|
||||
|
||||
// Loaded draw buffer entry points
|
||||
PFNGLDRAWBUFFERSEXTPROC mDrawBuffers;
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MultipleDrawBuffersSample app;
|
||||
return app.run();
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
precision mediump float;
|
||||
varying vec2 v_texCoord;
|
||||
uniform sampler2D s_texture;
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D(s_texture, v_texCoord);
|
||||
gl_FragColor = color;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#extension GL_EXT_draw_buffers : enable
|
||||
precision mediump float;
|
||||
varying vec2 v_texCoord;
|
||||
uniform sampler2D s_texture;
|
||||
void main()
|
||||
{
|
||||
vec4 color = texture2D(s_texture, v_texCoord);
|
||||
gl_FragData[0] = color;
|
||||
gl_FragData[1] = vec4(1.0, 1.0, 1.0, 1.0) - color.brga;
|
||||
gl_FragData[2] = vec4(0.2, 1.0, 0.5, 1.0) * color.gbra;
|
||||
gl_FragData[3] = color.rrra;
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
attribute vec4 a_position;
|
||||
attribute vec2 a_texCoord;
|
||||
varying vec2 v_texCoord;
|
||||
void main()
|
||||
{
|
||||
gl_Position = a_position;
|
||||
v_texCoord = a_texCoord;
|
||||
}
|
|
@ -8,6 +8,27 @@
|
|||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
static std::string ReadFileToString(const std::string &source)
|
||||
{
|
||||
std::ifstream stream(source);
|
||||
if (!stream)
|
||||
{
|
||||
std::cerr << "Failed to load shader file: " << source;
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string result;
|
||||
|
||||
stream.seekg(0, std::ios::end);
|
||||
result.reserve(stream.tellg());
|
||||
stream.seekg(0, std::ios::beg);
|
||||
|
||||
result.assign((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GLuint CompileShader(GLenum type, const std::string &source)
|
||||
{
|
||||
|
@ -37,6 +58,17 @@ GLuint CompileShader(GLenum type, const std::string &source)
|
|||
return shader;
|
||||
}
|
||||
|
||||
GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath)
|
||||
{
|
||||
std::string source = ReadFileToString(sourcePath);
|
||||
if (source.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return CompileShader(type, source);
|
||||
}
|
||||
|
||||
GLuint CompileProgram(const std::string &vsSource, const std::string &fsSource)
|
||||
{
|
||||
GLuint program = glCreateProgram();
|
||||
|
@ -79,3 +111,15 @@ GLuint CompileProgram(const std::string &vsSource, const std::string &fsSource)
|
|||
|
||||
return program;
|
||||
}
|
||||
|
||||
GLuint CompileProgramFromFiles(const std::string &vsPath, const std::string &fsPath)
|
||||
{
|
||||
std::string vsSource = ReadFileToString(vsPath);
|
||||
std::string fsSource = ReadFileToString(fsPath);
|
||||
if (vsSource.empty() || fsSource.empty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return CompileProgram(vsSource, fsSource);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
#define SHADER_SOURCE(...) #__VA_ARGS__
|
||||
|
||||
GLuint CompileShader(GLenum type, const std::string &source);
|
||||
GLuint CompileShaderFromFile(GLenum type, const std::string &sourcePath);
|
||||
|
||||
GLuint CompileProgram(const std::string &vsSource, const std::string &fsSource);
|
||||
GLuint CompileProgramFromFiles(const std::string &vsPath, const std::string &fsPath);
|
||||
|
||||
#endif // SAMPLE_UTIL_SHADER_UTILS_H
|
||||
|
|
|
@ -1,295 +0,0 @@
|
|||
//
|
||||
// Modified from Simple_Texture2D, found in:
|
||||
//
|
||||
// Book: OpenGL(R) ES 2.0 Programming Guide
|
||||
// Authors: Aaftab Munshi, Dan Ginsburg, Dave Shreiner
|
||||
// ISBN-10: 0321502795
|
||||
// ISBN-13: 9780321502797
|
||||
// Publisher: Addison-Wesley Professional
|
||||
// URLs: http://safari.informit.com/9780321563835
|
||||
// http://www.opengles-book.com
|
||||
//
|
||||
|
||||
// MultipleRenderTargets.c
|
||||
//
|
||||
// This is a simple example that shows how to use multiple render
|
||||
// targets in GLES 2.0 using EXT_draw_buffers. The example
|
||||
// draws to three render targets and displays
|
||||
// them together in a final pass.
|
||||
//
|
||||
#include <stdlib.h>
|
||||
#include "esUtil.h"
|
||||
|
||||
PFNGLDRAWBUFFERSEXTPROC glDrawBuffersEXT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Handle to a program object
|
||||
GLuint programObjectMRT;
|
||||
GLuint programObject;
|
||||
|
||||
// Attribute locations
|
||||
GLint positionLoc;
|
||||
GLint texCoordLoc;
|
||||
|
||||
// Sampler location
|
||||
GLint samplerLoc;
|
||||
|
||||
// Texture handle
|
||||
GLuint textureId;
|
||||
|
||||
// Framebuffer object handle
|
||||
GLuint framebuffer;
|
||||
|
||||
// Framebuffer color attachments
|
||||
GLuint framebufferTextures[4];
|
||||
|
||||
} UserData;
|
||||
|
||||
///
|
||||
// Create a simple 2x2 texture image with four different colors
|
||||
//
|
||||
GLuint CreateSimpleTexture2D( )
|
||||
{
|
||||
// Texture object handle
|
||||
GLuint textureId;
|
||||
|
||||
// 2x2 Image, 3 bytes per pixel (R, G, B)
|
||||
GLubyte pixels[4 * 3] =
|
||||
{
|
||||
255, 0, 0, // Red
|
||||
0, 255, 0, // Green
|
||||
0, 0, 255, // Blue
|
||||
255, 255, 0 // Yellow
|
||||
};
|
||||
|
||||
// Use tightly packed data
|
||||
glPixelStorei ( GL_UNPACK_ALIGNMENT, 1 );
|
||||
|
||||
// Generate a texture object
|
||||
glGenTextures ( 1, &textureId );
|
||||
|
||||
// Bind the texture object
|
||||
glBindTexture ( GL_TEXTURE_2D, textureId );
|
||||
|
||||
// Load the texture
|
||||
glTexImage2D ( GL_TEXTURE_2D, 0, GL_RGB, 2, 2, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels );
|
||||
|
||||
// Set the filtering mode
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
|
||||
return textureId;
|
||||
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
// Initialize the shader and program object
|
||||
//
|
||||
int Init ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = (UserData*)esContext->userData;
|
||||
GLbyte vShaderStr[] =
|
||||
"attribute vec4 a_position; \n"
|
||||
"attribute vec2 a_texCoord; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" gl_Position = a_position; \n"
|
||||
" v_texCoord = a_texCoord; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fMultiShaderStr[] =
|
||||
"#extension GL_EXT_draw_buffers : enable \n"
|
||||
"precision mediump float; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"uniform sampler2D s_texture; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" vec4 color = texture2D( s_texture, v_texCoord ); \n"
|
||||
" gl_FragData[0] = color; \n"
|
||||
" gl_FragData[1] = vec4(1.0, 1.0, 1.0, 1.0) - color.brga;\n"
|
||||
" gl_FragData[2] = vec4(0.2, 1.0, 0.5, 1.0) * color.gbra;\n"
|
||||
" gl_FragData[3] = color.rrra; \n"
|
||||
"} \n";
|
||||
|
||||
GLbyte fShaderStr[] =
|
||||
"precision mediump float; \n"
|
||||
"varying vec2 v_texCoord; \n"
|
||||
"uniform sampler2D s_texture; \n"
|
||||
"void main() \n"
|
||||
"{ \n"
|
||||
" vec4 color = texture2D( s_texture, v_texCoord ); \n"
|
||||
" gl_FragColor = color; \n"
|
||||
"} \n";
|
||||
|
||||
int i;
|
||||
|
||||
// Check EXT_draw_buffers is supported
|
||||
if (strstr(glGetString(GL_EXTENSIONS), "GL_EXT_draw_buffers") == 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Retrieve the address of glDrawBuffersEXT from EGL
|
||||
glDrawBuffersEXT = (PFNGLDRAWBUFFERSEXTPROC)eglGetProcAddress("glDrawBuffersEXT");
|
||||
|
||||
// Load the shaders and get a linked program object
|
||||
userData->programObject = esLoadProgram ( (const char*)vShaderStr, (const char*)fShaderStr );
|
||||
|
||||
userData->programObjectMRT = esLoadProgram ( (const char*)vShaderStr, (const char*)fMultiShaderStr );
|
||||
|
||||
// Get the attribute locations
|
||||
userData->positionLoc = glGetAttribLocation ( userData->programObject, "a_position" );
|
||||
userData->texCoordLoc = glGetAttribLocation ( userData->programObject, "a_texCoord" );
|
||||
|
||||
// Get the sampler location
|
||||
userData->samplerLoc = glGetUniformLocation ( userData->programObject, "s_texture" );
|
||||
|
||||
// Load the texture
|
||||
userData->textureId = CreateSimpleTexture2D ();
|
||||
|
||||
glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );
|
||||
|
||||
// Initialize the user framebuffer
|
||||
glGenFramebuffers(1, &userData->framebuffer);
|
||||
glGenTextures(4, userData->framebufferTextures);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, userData->framebuffer);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
// Create textures for the four color attachments
|
||||
glBindTexture(GL_TEXTURE_2D, userData->framebufferTextures[i]);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, esContext->width, esContext->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, userData->framebufferTextures[i], 0);
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
///
|
||||
// Draw a triangle using the shader pair created in Init()
|
||||
//
|
||||
void Draw ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = (UserData*)esContext->userData;
|
||||
GLfloat vVertices[] = { -0.8f, 0.8f, 0.0f, // Position 0
|
||||
0.0f, 0.0f, // TexCoord 0
|
||||
-0.8f, -0.8f, 0.0f, // Position 1
|
||||
0.0f, 1.0f, // TexCoord 1
|
||||
0.8f, -0.8f, 0.0f, // Position 2
|
||||
1.0f, 1.0f, // TexCoord 2
|
||||
0.8f, 0.8f, 0.0f, // Position 3
|
||||
1.0f, 0.0f // TexCoord 3
|
||||
};
|
||||
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
|
||||
|
||||
GLenum drawBuffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_COLOR_ATTACHMENT2_EXT, GL_COLOR_ATTACHMENT3_EXT };
|
||||
|
||||
// Enable drawing to the four color attachments of the user framebuffer
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, userData->framebuffer);
|
||||
glDrawBuffersEXT(4, drawBuffers);
|
||||
|
||||
// Set the viewport
|
||||
glViewport ( 0, 0, esContext->width, esContext->height );
|
||||
|
||||
// Clear the color buffer
|
||||
glClear ( GL_COLOR_BUFFER_BIT );
|
||||
|
||||
// Use the program object
|
||||
glUseProgram ( userData->programObjectMRT );
|
||||
|
||||
// Load the vertex position
|
||||
glVertexAttribPointer ( userData->positionLoc, 3, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), vVertices );
|
||||
// Load the texture coordinate
|
||||
glVertexAttribPointer ( userData->texCoordLoc, 2, GL_FLOAT,
|
||||
GL_FALSE, 5 * sizeof(GLfloat), &vVertices[3] );
|
||||
|
||||
glEnableVertexAttribArray ( userData->positionLoc );
|
||||
glEnableVertexAttribArray ( userData->texCoordLoc );
|
||||
|
||||
// Bind the texture
|
||||
glActiveTexture ( GL_TEXTURE0 );
|
||||
glBindTexture ( GL_TEXTURE_2D, userData->textureId );
|
||||
|
||||
// Set the sampler texture unit to 0
|
||||
glUniform1i ( userData->samplerLoc, 0 );
|
||||
|
||||
// Draw the textured quad to the four render targets
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
// Enable the default framebuffer and single textured drawing
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glUseProgram ( userData->programObject );
|
||||
|
||||
// Draw the four textured quads to a separate region in the viewport
|
||||
glBindTexture( GL_TEXTURE_2D, userData->framebufferTextures[0]);
|
||||
glViewport ( 0, 0, esContext->width/2, esContext->height/2 );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, userData->framebufferTextures[1]);
|
||||
glViewport ( esContext->width/2, 0, esContext->width/2, esContext->height/2 );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, userData->framebufferTextures[2]);
|
||||
glViewport ( 0, esContext->height/2, esContext->width/2, esContext->height/2 );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, userData->framebufferTextures[3]);
|
||||
glViewport ( esContext->width/2, esContext->height/2, esContext->width/2, esContext->height/2 );
|
||||
glDrawElements ( GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices );
|
||||
|
||||
eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface );
|
||||
}
|
||||
|
||||
///
|
||||
// Cleanup
|
||||
//
|
||||
void ShutDown ( ESContext *esContext )
|
||||
{
|
||||
UserData *userData = (UserData*)esContext->userData;
|
||||
|
||||
glDeleteTextures(4, userData->framebufferTextures);
|
||||
|
||||
glDeleteFramebuffers(1, &userData->framebuffer);
|
||||
|
||||
// Delete texture object
|
||||
glDeleteTextures ( 1, &userData->textureId );
|
||||
|
||||
// Delete program object
|
||||
glDeleteProgram ( userData->programObject );
|
||||
|
||||
eglDestroyContext(esContext->eglDisplay, esContext->eglContext);
|
||||
eglDestroySurface(esContext->eglDisplay, esContext->eglSurface);
|
||||
eglTerminate(esContext->eglDisplay);
|
||||
}
|
||||
|
||||
|
||||
int main ( int argc, char *argv[] )
|
||||
{
|
||||
ESContext esContext;
|
||||
UserData userData;
|
||||
|
||||
esInitContext ( &esContext );
|
||||
esContext.userData = &userData;
|
||||
|
||||
esCreateWindow ( &esContext, TEXT("Multiple Render Targets"), 320, 240, ES_WINDOW_RGB );
|
||||
|
||||
if ( !Init ( &esContext ) )
|
||||
return 0;
|
||||
|
||||
esRegisterDrawFunc ( &esContext, Draw );
|
||||
|
||||
esMainLoop ( &esContext );
|
||||
|
||||
ShutDown ( &esContext );
|
||||
}
|
|
@ -148,6 +148,20 @@
|
|||
'sources': [ '<!@(python <(angle_path)/enumerate_files.py angle/simple_instancing -types *.cpp *.h)' ],
|
||||
},
|
||||
|
||||
{
|
||||
'target_name': 'multiple_draw_buffers',
|
||||
'type': 'executable',
|
||||
'dependencies': [ 'sample_util' ],
|
||||
'sources': [ '<!@(python <(angle_path)/enumerate_files.py angle/multiple_draw_buffers -types *.cpp *.h *.glsl)' ],
|
||||
'copies':
|
||||
[
|
||||
{
|
||||
'destination': '<(PRODUCT_DIR)',
|
||||
'files': [ '<!@(python <(angle_path)/enumerate_files.py angle/multiple_draw_buffers -types *.glsl)' ],
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
'target_name': 'simple_texture_2d',
|
||||
'type': 'executable',
|
||||
|
|
Загрузка…
Ссылка в новой задаче