completed last commit
This commit is contained in:
parent
df1f49462f
commit
c0f90ca5b6
@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.RenderSystem.Windows.GL3</RootNamespace>
|
||||
<AssemblyName>ANX.RenderSystem.Windows.GL3</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;XNAEXT</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;XNAEXT</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BlendStateGL3.cs" />
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="Helpers\DatatypesMapping.cs" />
|
||||
<Compile Include="DepthStencilStateGL3.cs" />
|
||||
<Compile Include="EffectGL3.cs" />
|
||||
<Compile Include="EffectParameterGL3.cs" />
|
||||
<Compile Include="EffectPassGL3.cs" />
|
||||
<Compile Include="EffectTechniqueGL3.cs" />
|
||||
<Compile Include="ErrorHelper.cs" />
|
||||
<Compile Include="GraphicsDeviceWindowsGL3.cs" />
|
||||
<Compile Include="Helpers\GraphicsResourceManager.cs" />
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
<Compile Include="SamplerStateGL3.cs" />
|
||||
<Compile Include="ShaderAttributeGL3.cs" />
|
||||
<Compile Include="ShaderByteCode.cs" />
|
||||
<Compile Include="ShaderData.cs" />
|
||||
<Compile Include="ShaderHelper.cs" />
|
||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||
<Compile Include="Texture2DGL3.cs" />
|
||||
<Compile Include="VertexBufferGL3.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework.csproj">
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@ -1,89 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.RenderSystem.Windows.GL3</RootNamespace>
|
||||
<AssemblyName>ANX.RenderSystem.Windows.GL3</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>XNAEXT;DEBUG;TRACE;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<DefineConstants>XNAEXT;TRACE;LINUX;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BlendStateGL3.cs" />
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="Helpers\DatatypesMapping.cs" />
|
||||
<Compile Include="DepthStencilStateGL3.cs" />
|
||||
<Compile Include="EffectGL3.cs" />
|
||||
<Compile Include="EffectParameterGL3.cs" />
|
||||
<Compile Include="EffectPassGL3.cs" />
|
||||
<Compile Include="EffectTechniqueGL3.cs" />
|
||||
<Compile Include="ErrorHelper.cs" />
|
||||
<Compile Include="GraphicsDeviceWindowsGL3.cs" />
|
||||
<Compile Include="Helpers\GraphicsResourceManager.cs" />
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
<Compile Include="SamplerStateGL3.cs" />
|
||||
<Compile Include="ShaderAttributeGL3.cs" />
|
||||
<Compile Include="ShaderByteCode.cs" />
|
||||
<Compile Include="ShaderData.cs" />
|
||||
<Compile Include="ShaderHelper.cs" />
|
||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||
<Compile Include="Texture2DGL3.cs" />
|
||||
<Compile Include="VertexBufferGL3.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_Linux.csproj">
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent></PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.RenderSystem.Windows.GL3</RootNamespace>
|
||||
<AssemblyName>ANX.RenderSystem.Windows.GL3</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{69878862-DA7D-4DC6-B0A1-50D8FAB4242F};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>XNAEXT;DEBUG;TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<DefineConstants>XNAEXT;TRACE;PSVITA;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BlendStateGL3.cs" />
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="Helpers\DatatypesMapping.cs" />
|
||||
<Compile Include="DepthStencilStateGL3.cs" />
|
||||
<Compile Include="EffectGL3.cs" />
|
||||
<Compile Include="EffectParameterGL3.cs" />
|
||||
<Compile Include="EffectPassGL3.cs" />
|
||||
<Compile Include="EffectTechniqueGL3.cs" />
|
||||
<Compile Include="ErrorHelper.cs" />
|
||||
<Compile Include="GraphicsDeviceWindowsGL3.cs" />
|
||||
<Compile Include="Helpers\GraphicsResourceManager.cs" />
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
<Compile Include="SamplerStateGL3.cs" />
|
||||
<Compile Include="ShaderAttributeGL3.cs" />
|
||||
<Compile Include="ShaderByteCode.cs" />
|
||||
<Compile Include="ShaderData.cs" />
|
||||
<Compile Include="ShaderHelper.cs" />
|
||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||
<Compile Include="Texture2DGL3.cs" />
|
||||
<Compile Include="VertexBufferGL3.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_PSVita.csproj">
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Sce\Sce.Psm.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent></PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
@ -1,95 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.RenderSystem.Windows.GL3</RootNamespace>
|
||||
<AssemblyName>ANX.RenderSystem.Windows.GL3</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{BC8A1FFA-BEE3-4634-8014-F334798102B3};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<PackageCertificateKeyFile>Test_TemporaryKey.pfx</PackageCertificateKeyFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>XNAEXT;DEBUG;TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\bin\Release\</OutputPath>
|
||||
<DefineConstants>XNAEXT;TRACE;WINDOWSMETRO;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="OpenTK">
|
||||
<HintPath>..\..\lib\OpenTK\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BlendStateGL3.cs" />
|
||||
<Compile Include="Creator.cs" />
|
||||
<Compile Include="Helpers\DatatypesMapping.cs" />
|
||||
<Compile Include="DepthStencilStateGL3.cs" />
|
||||
<Compile Include="EffectGL3.cs" />
|
||||
<Compile Include="EffectParameterGL3.cs" />
|
||||
<Compile Include="EffectPassGL3.cs" />
|
||||
<Compile Include="EffectTechniqueGL3.cs" />
|
||||
<Compile Include="ErrorHelper.cs" />
|
||||
<Compile Include="GraphicsDeviceWindowsGL3.cs" />
|
||||
<Compile Include="Helpers\GraphicsResourceManager.cs" />
|
||||
<Compile Include="Helpers\LinuxInterop.cs" />
|
||||
<Compile Include="Helpers\WindowsInterop.cs" />
|
||||
<Compile Include="IndexBufferGL3.cs" />
|
||||
<Compile Include="OcclusionQueryGL3.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RasterizerStateGL3.cs" />
|
||||
<Compile Include="RenderTarget2DGL3.cs" />
|
||||
<Compile Include="SamplerStateGL3.cs" />
|
||||
<Compile Include="ShaderAttributeGL3.cs" />
|
||||
<Compile Include="ShaderByteCode.cs" />
|
||||
<Compile Include="ShaderData.cs" />
|
||||
<Compile Include="ShaderHelper.cs" />
|
||||
<Compile Include="SupportedPlatformsImpl.cs" />
|
||||
<Compile Include="Texture2DGL3.cs" />
|
||||
<Compile Include="VertexBufferGL3.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework_WindowsMetro.csproj">
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent></PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '11.0' ">
|
||||
<VisualStudioVersion>11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
</Project>
|
@ -1,353 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using ANX.RenderSystem.Windows.GL3.Helpers;
|
||||
using ANX.Framework;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native Blend State object for OpenGL.
|
||||
/// <para />
|
||||
/// Basically this is a wrapper class for setting the different values all
|
||||
/// at once, because OpenGL has no State objects like DirectX.
|
||||
/// <para />
|
||||
/// For Information on OpenGL blending: http://www.opengl.org/wiki/Blending
|
||||
/// </summary>
|
||||
[PercentageComplete(90)]
|
||||
[TestStateAttribute(TestStateAttribute.TestState.Untested)]
|
||||
public class BlendStateGL3 : INativeBlendState
|
||||
{
|
||||
#region Private
|
||||
internal static BlendStateGL3 Current
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
#region IsBound
|
||||
/// <summary>
|
||||
/// Flag if the blend state is bound to the device or not.
|
||||
/// </summary>
|
||||
public bool IsBound
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AlphaBlendFunction
|
||||
public BlendFunction AlphaBlendFunction
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ColorBlendFunction
|
||||
public BlendFunction ColorBlendFunction
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AlphaSourceBlend
|
||||
public Blend AlphaSourceBlend
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AlphaDestinationBlend
|
||||
public Blend AlphaDestinationBlend
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ColorSourceBlend
|
||||
public Blend ColorSourceBlend
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ColorDestinationBlend
|
||||
public Blend ColorDestinationBlend
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ColorWriteChannels
|
||||
public ColorWriteChannels ColorWriteChannels
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ColorWriteChannels1
|
||||
public ColorWriteChannels ColorWriteChannels1
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ColorWriteChannels2
|
||||
public ColorWriteChannels ColorWriteChannels2
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ColorWriteChannels3
|
||||
public ColorWriteChannels ColorWriteChannels3
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BlendFactor
|
||||
public Color BlendFactor
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MultiSampleMask
|
||||
public int MultiSampleMask
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a new OpenGL Blend State wrapper object.
|
||||
/// </summary>
|
||||
internal BlendStateGL3()
|
||||
{
|
||||
IsBound = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply (TODO)
|
||||
/// <summary>
|
||||
/// Apply the blend state on the graphics device.
|
||||
/// </summary>
|
||||
/// <param name="graphicsDevice">The current graphics device.</param>
|
||||
public void Apply(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
IsBound = true;
|
||||
Current = this;
|
||||
|
||||
GL.Enable(EnableCap.Blend);
|
||||
|
||||
GL.BlendEquationSeparate(
|
||||
TranslateBlendFunction(ColorBlendFunction),
|
||||
TranslateBlendFunction(AlphaBlendFunction));
|
||||
ErrorHelper.Check("BlendEquationSeparate");
|
||||
|
||||
GL.BlendFuncSeparate(
|
||||
TranslateBlendSrc(ColorSourceBlend),
|
||||
TranslateBlendDest(ColorDestinationBlend),
|
||||
TranslateBlendSrc(AlphaSourceBlend),
|
||||
TranslateBlendDest(AlphaDestinationBlend));
|
||||
ErrorHelper.Check("BlendFuncSeparate");
|
||||
|
||||
SetColorWriteChannel(0, ColorWriteChannels);
|
||||
SetColorWriteChannel(1, ColorWriteChannels1);
|
||||
SetColorWriteChannel(2, ColorWriteChannels2);
|
||||
SetColorWriteChannel(3, ColorWriteChannels3);
|
||||
|
||||
GL.BlendColor(BlendFactor.R * DatatypesMapping.ColorMultiplier,
|
||||
BlendFactor.G * DatatypesMapping.ColorMultiplier,
|
||||
BlendFactor.B * DatatypesMapping.ColorMultiplier,
|
||||
BlendFactor.A * DatatypesMapping.ColorMultiplier);
|
||||
ErrorHelper.Check("BlendColor");
|
||||
|
||||
// TODO: multi sample mask
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Release
|
||||
/// <summary>
|
||||
/// Release the blend state.
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
IsBound = false;
|
||||
Current = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose this blend state object.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetColorWriteChannel
|
||||
/// <summary>
|
||||
/// Set the color mask for the specified index.
|
||||
/// </summary>
|
||||
/// <param name="index">Index of the color mask.</param>
|
||||
/// <param name="channels">Mask channels to enable.</param>
|
||||
private void SetColorWriteChannel(int index, ColorWriteChannels channels)
|
||||
{
|
||||
bool r = (channels | ColorWriteChannels.Red) == channels;
|
||||
bool g = (channels | ColorWriteChannels.Green) == channels;
|
||||
bool b = (channels | ColorWriteChannels.Blue) == channels;
|
||||
bool a = (channels | ColorWriteChannels.Alpha) == channels;
|
||||
|
||||
GL.ColorMask(index, r, g, b, a);
|
||||
ErrorHelper.Check("ColorMask");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TranslateBlendSrc
|
||||
/// <summary>
|
||||
/// Translate the ANX Blend mode to the OpenGL Blend Factor Source.
|
||||
/// </summary>
|
||||
/// <param name="func">ANX Blend Function.</param>
|
||||
/// <returns>OpenGL Blend Factor Source.</returns>
|
||||
private BlendingFactorSrc TranslateBlendSrc(Blend blending)
|
||||
{
|
||||
switch (blending)
|
||||
{
|
||||
case Blend.SourceAlpha:
|
||||
return BlendingFactorSrc.SrcAlpha;
|
||||
|
||||
case Blend.DestinationAlpha:
|
||||
return BlendingFactorSrc.DstAlpha;
|
||||
|
||||
case Blend.DestinationColor:
|
||||
return BlendingFactorSrc.DstColor;
|
||||
|
||||
case Blend.InverseDestinationAlpha:
|
||||
return BlendingFactorSrc.OneMinusDstAlpha;
|
||||
|
||||
case Blend.InverseDestinationColor:
|
||||
return BlendingFactorSrc.OneMinusDstColor;
|
||||
|
||||
case Blend.InverseSourceAlpha:
|
||||
return BlendingFactorSrc.OneMinusSrcAlpha;
|
||||
|
||||
case Blend.One:
|
||||
return BlendingFactorSrc.One;
|
||||
|
||||
case Blend.SourceAlphaSaturation:
|
||||
return BlendingFactorSrc.SrcAlphaSaturate;
|
||||
|
||||
case Blend.Zero:
|
||||
return BlendingFactorSrc.Zero;
|
||||
|
||||
default:
|
||||
throw new ArgumentException("Unable to translate SourceBlend '" +
|
||||
blending + "' to OpenGL BlendingFactorSrc.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TranslateBlendDest
|
||||
/// <summary>
|
||||
/// Translate the ANX Blend mode to the OpenGL Blend Factor Destination.
|
||||
/// </summary>
|
||||
/// <param name="func">ANX Blend Function.</param>
|
||||
/// <returns>OpenGL Blend Factor Destination.</returns>
|
||||
private BlendingFactorDest TranslateBlendDest(Blend blending)
|
||||
{
|
||||
switch (blending)
|
||||
{
|
||||
case Blend.SourceAlpha:
|
||||
return BlendingFactorDest.SrcAlpha;
|
||||
|
||||
case Blend.DestinationAlpha:
|
||||
return BlendingFactorDest.DstAlpha;
|
||||
|
||||
case Blend.DestinationColor:
|
||||
return BlendingFactorDest.DstColor;
|
||||
|
||||
case Blend.InverseDestinationAlpha:
|
||||
return BlendingFactorDest.OneMinusDstAlpha;
|
||||
|
||||
case Blend.InverseDestinationColor:
|
||||
return BlendingFactorDest.OneMinusDstColor;
|
||||
|
||||
case Blend.InverseSourceAlpha:
|
||||
return BlendingFactorDest.OneMinusSrcAlpha;
|
||||
|
||||
case Blend.InverseSourceColor:
|
||||
return BlendingFactorDest.OneMinusSrcColor;
|
||||
|
||||
case Blend.One:
|
||||
return BlendingFactorDest.One;
|
||||
|
||||
case Blend.SourceColor:
|
||||
return BlendingFactorDest.SrcColor;
|
||||
|
||||
case Blend.Zero:
|
||||
return BlendingFactorDest.Zero;
|
||||
|
||||
default:
|
||||
throw new ArgumentException("Unable to translate DestinationBlend '" +
|
||||
blending + "' to OpenGL BlendingFactorDest.");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TranslateBlendFunction
|
||||
/// <summary>
|
||||
/// Translate the ANX Blend Function to the OpenGL Blend Equation Mode.
|
||||
/// </summary>
|
||||
/// <param name="func">ANX Blend Function.</param>
|
||||
/// <returns>OpenGL Blend Equation Mode.</returns>
|
||||
private BlendEquationMode TranslateBlendFunction(BlendFunction func)
|
||||
{
|
||||
switch (func)
|
||||
{
|
||||
case BlendFunction.Add:
|
||||
return BlendEquationMode.FuncAdd;
|
||||
|
||||
case BlendFunction.Subtract:
|
||||
return BlendEquationMode.FuncSubtract;
|
||||
|
||||
case BlendFunction.ReverseSubtract:
|
||||
return BlendEquationMode.FuncReverseSubtract;
|
||||
|
||||
case BlendFunction.Min:
|
||||
return BlendEquationMode.Min;
|
||||
|
||||
case BlendFunction.Max:
|
||||
return BlendEquationMode.Max;
|
||||
}
|
||||
|
||||
throw new ArgumentException("Unable to translate BlendFunction '" +
|
||||
func + "' to OpenGL BlendEquationMode.");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,347 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using ANX.Framework;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using ANX.Framework.Windows.GL3;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
[PercentageComplete(90)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
[Developer("AstrorEnales")]
|
||||
public class Creator : IRenderSystemCreator
|
||||
{
|
||||
#region Public
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "OpenGL3";
|
||||
}
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
//TODO: this is just a very basic version of test for support
|
||||
PlatformName os = OSInformation.GetName();
|
||||
return OSInformation.IsWindows ||
|
||||
os == PlatformName.Linux ||
|
||||
os == PlatformName.MacOSX;
|
||||
}
|
||||
}
|
||||
|
||||
public EffectSourceLanguage GetStockShaderSourceLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
return EffectSourceLanguage.GLSL_FX;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateEffect
|
||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
||||
Stream byteCode)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(
|
||||
AddInType.RenderSystem);
|
||||
|
||||
return new EffectGL3(managedEffect, byteCode);
|
||||
}
|
||||
|
||||
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
|
||||
Stream vertexShaderByteCode, Stream pixelShaderByteCode)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(
|
||||
AddInType.RenderSystem);
|
||||
|
||||
return new EffectGL3(managedEffect, vertexShaderByteCode, pixelShaderByteCode);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateGraphicsDevice
|
||||
INativeGraphicsDevice IRenderSystemCreator.CreateGraphicsDevice(PresentationParameters presentationParameters)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new GraphicsDeviceWindowsGL3(presentationParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateTexture
|
||||
/// <summary>
|
||||
/// Create a new native texture.
|
||||
/// </summary>
|
||||
/// <param name="graphics">Graphics device.</param>
|
||||
/// <param name="surfaceFormat">The format of the texture.</param>
|
||||
/// <param name="width">The width of the texture.</param>
|
||||
/// <param name="height">The height of the texture.</param>
|
||||
/// <param name="mipCount">The number of mipmaps in the texture.</param>
|
||||
/// <returns></returns>
|
||||
public INativeTexture2D CreateTexture(GraphicsDevice graphics,
|
||||
SurfaceFormat surfaceFormat, int width, int height, int mipCount)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new Texture2DGL3(surfaceFormat, width, height, mipCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateIndexBuffer
|
||||
/// <summary>
|
||||
/// Create a native index buffer.
|
||||
/// </summary>
|
||||
/// <param name="graphics">The current graphics device.</param>
|
||||
/// <param name="size">The size of a single index element.</param>
|
||||
/// <param name="indexCount">The number of indices stored in the buffer.
|
||||
/// </param>
|
||||
/// <param name="usage">The usage type of the buffer.</param>
|
||||
/// <returns>Native OpenGL index buffer.</returns>
|
||||
public INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics,
|
||||
IndexBuffer managedBuffer, IndexElementSize size, int indexCount,
|
||||
BufferUsage usage)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new IndexBufferGL3(managedBuffer, size, indexCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateVertexBuffer
|
||||
/// <summary>
|
||||
/// Create a native vertex buffer.
|
||||
/// </summary>
|
||||
/// <param name="graphics">The current graphics device.</param>
|
||||
/// <param name="size">The vertex declaration for the buffer.</param>
|
||||
/// <param name="indexCount">The number of vertices stored in the buffer.
|
||||
/// </param>
|
||||
/// <param name="usage">The usage type of the buffer.</param>
|
||||
/// <returns>Native OpenGL vertex buffer.</returns>
|
||||
public INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics,
|
||||
VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration,
|
||||
int vertexCount, BufferUsage usage)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new VertexBufferGL3(managedBuffer, vertexDeclaration, vertexCount,
|
||||
usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#if XNAEXT
|
||||
#region CreateConstantBuffer (TODO)
|
||||
public INativeConstantBuffer CreateConstantBuffer(GraphicsDevice graphics, ConstantBuffer managedBuffer,
|
||||
BufferUsage usage)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
#endif
|
||||
|
||||
#region CreateBlendState
|
||||
/// <summary>
|
||||
/// Create a new native blend state.
|
||||
/// </summary>
|
||||
/// <returns>Native Blend State.</returns>
|
||||
public INativeBlendState CreateBlendState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new BlendStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateBlendState
|
||||
/// <summary>
|
||||
/// Create a new native rasterizer state.
|
||||
/// </summary>
|
||||
/// <returns>Native Rasterizer State.</returns>
|
||||
public INativeRasterizerState CreateRasterizerState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new RasterizerStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateDepthStencilState
|
||||
/// <summary>
|
||||
/// Create a new native Depth Stencil State.
|
||||
/// </summary>
|
||||
/// <returns>Native Depth Stencil State.</returns>
|
||||
public INativeDepthStencilState CreateDepthStencilState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new DepthStencilStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateSamplerState
|
||||
/// <summary>
|
||||
/// Create a new native sampler state.
|
||||
/// </summary>
|
||||
/// <returns>Native Sampler State.</returns>
|
||||
public INativeSamplerState CreateSamplerState()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new SamplerStateGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetShaderByteCode
|
||||
/// <summary>
|
||||
/// Get the byte code of a pre defined shader.
|
||||
/// </summary>
|
||||
/// <param name="type">Pre defined shader type.</param>
|
||||
/// <returns>Byte code of the shader.</returns>
|
||||
public byte[] GetShaderByteCode(PreDefinedShader type)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
|
||||
if (type == PreDefinedShader.SpriteBatch)
|
||||
{
|
||||
return ShaderByteCode.SpriteBatchByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.AlphaTestEffect)
|
||||
{
|
||||
return ShaderByteCode.AlphaTestEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.BasicEffect)
|
||||
{
|
||||
return ShaderByteCode.BasicEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.DualTextureEffect)
|
||||
{
|
||||
return ShaderByteCode.DualTextureEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.EnvironmentMapEffect)
|
||||
{
|
||||
return ShaderByteCode.EnvironmentMapEffectByteCode;
|
||||
}
|
||||
else if (type == PreDefinedShader.SkinnedEffect)
|
||||
{
|
||||
return ShaderByteCode.SkinnedEffectByteCode;
|
||||
}
|
||||
|
||||
throw new NotImplementedException("ByteCode for '" + type.ToString() + "' is not yet available");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetAdapterList (TODO)
|
||||
/// <summary>
|
||||
/// Get a list of available graphics adapter information.
|
||||
/// </summary>
|
||||
/// <returns>List of graphics adapters.</returns>
|
||||
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
|
||||
var result = new List<GraphicsAdapter>();
|
||||
foreach (DisplayDevice device in DisplayDevice.AvailableDisplays)
|
||||
{
|
||||
var displayModeCollection = new DisplayModeCollection();
|
||||
foreach (string format in Enum.GetNames(typeof(SurfaceFormat)))
|
||||
{
|
||||
SurfaceFormat surfaceFormat =
|
||||
(SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format);
|
||||
|
||||
// TODO: device.BitsPerPixel
|
||||
if (surfaceFormat != SurfaceFormat.Color)//adapter.Supports(surfaceFormat) == false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var modes = new List<DisplayMode>();
|
||||
|
||||
foreach (DisplayResolution res in device.AvailableResolutions)
|
||||
{
|
||||
float aspect = (float)res.Width / (float)res.Height;
|
||||
modes.Add(new DisplayMode
|
||||
{
|
||||
AspectRatio = aspect,
|
||||
Width = res.Width,
|
||||
Height = res.Height,
|
||||
TitleSafeArea = new Rectangle(0, 0, res.Width, res.Height),
|
||||
Format = surfaceFormat,
|
||||
});
|
||||
}
|
||||
|
||||
displayModeCollection[surfaceFormat] = modes.ToArray();
|
||||
}
|
||||
|
||||
GraphicsAdapter newAdapter = new GraphicsAdapter
|
||||
{
|
||||
SupportedDisplayModes = displayModeCollection,
|
||||
IsDefaultAdapter = device.IsPrimary,
|
||||
|
||||
// TODO:
|
||||
DeviceId = 0,
|
||||
DeviceName = "",
|
||||
Revision = 0,
|
||||
SubSystemId = 0,
|
||||
VendorId = 0,
|
||||
};
|
||||
|
||||
result.Add(newAdapter);
|
||||
}
|
||||
|
||||
return new ReadOnlyCollection<GraphicsAdapter>(result);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateRenderTarget
|
||||
public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics,
|
||||
int width, int height, bool mipMap, SurfaceFormat preferredFormat,
|
||||
DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
|
||||
RenderTargetUsage usage)
|
||||
{
|
||||
AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem);
|
||||
return new RenderTarget2DGL3(width, height, mipMap, preferredFormat,
|
||||
preferredDepthFormat, preferredMultiSampleCount, usage);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IsLanguageSupported
|
||||
public bool IsLanguageSupported(EffectSourceLanguage sourceLanguage)
|
||||
{
|
||||
return sourceLanguage == EffectSourceLanguage.GLSL_FX || sourceLanguage == EffectSourceLanguage.GLSL;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateOcclusionQuery
|
||||
public IOcclusionQuery CreateOcclusionQuery()
|
||||
{
|
||||
return new OcclusionQueryGL3();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetTextureSampler (TODO)
|
||||
public void SetTextureSampler(int index, Texture value)
|
||||
{
|
||||
TextureUnit textureUnit = TextureUnit.Texture0 + index;
|
||||
GL.ActiveTexture(textureUnit);
|
||||
int handle = (value.NativeTexture as Texture2DGL3).NativeHandle;
|
||||
GL.BindTexture(TextureTarget.Texture2D, handle);
|
||||
int unitIndex = (int)(textureUnit - TextureUnit.Texture0);
|
||||
//GL.Uniform1(UniformIndex, 1, ref unitIndex);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,400 +0,0 @@
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native Depth Stencil State object for OpenGL.
|
||||
/// <para />
|
||||
/// Basically this is a wrapper class for setting the different values all
|
||||
/// at once, because OpenGL has no State objects like DirectX.
|
||||
/// </summary>
|
||||
[PercentageComplete(100)]
|
||||
[TestStateAttribute(TestStateAttribute.TestState.Untested)]
|
||||
public class DepthStencilStateGL3 : INativeDepthStencilState
|
||||
{
|
||||
#region Private
|
||||
internal static DepthStencilStateGL3 Current
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
#region IsBound
|
||||
/// <summary>
|
||||
/// Flag if the state object is bound to the device.
|
||||
/// </summary>
|
||||
public bool IsBound
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DepthBufferEnable
|
||||
public bool DepthBufferEnable
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DepthBufferFunction
|
||||
public CompareFunction DepthBufferFunction
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DepthBufferWriteEnable
|
||||
public bool DepthBufferWriteEnable
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StencilEnable
|
||||
public bool StencilEnable
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StencilFunction
|
||||
public CompareFunction StencilFunction
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StencilMask
|
||||
public int StencilMask
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StencilDepthBufferFail
|
||||
public StencilOperation StencilDepthBufferFail
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StencilFail
|
||||
public StencilOperation StencilFail
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StencilPass
|
||||
public StencilOperation StencilPass
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CounterClockwiseStencilDepthBufferFail
|
||||
public StencilOperation CounterClockwiseStencilDepthBufferFail
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CounterClockwiseStencilFail
|
||||
public StencilOperation CounterClockwiseStencilFail
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CounterClockwiseStencilFunction
|
||||
public CompareFunction CounterClockwiseStencilFunction
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CounterClockwiseStencilPass
|
||||
public StencilOperation CounterClockwiseStencilPass
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TwoSidedStencilMode
|
||||
public bool TwoSidedStencilMode
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ReferenceStencil
|
||||
public int ReferenceStencil
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region StencilWriteMask
|
||||
public int StencilWriteMask
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a new depth stencil state object.
|
||||
/// </summary>
|
||||
internal DepthStencilStateGL3()
|
||||
{
|
||||
IsBound = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply
|
||||
/// <summary>
|
||||
/// Apply the depth stencil state to the graphics device.
|
||||
/// </summary>
|
||||
/// <param name="graphicsDevice">The current graphics device.</param>
|
||||
public void Apply(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
IsBound = true;
|
||||
Current = this;
|
||||
|
||||
#region Depth
|
||||
if (DepthBufferEnable)
|
||||
{
|
||||
GL.Enable(EnableCap.DepthTest);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Disable(EnableCap.DepthTest);
|
||||
}
|
||||
ErrorHelper.Check("DepthTest");
|
||||
|
||||
GL.DepthFunc(TranslateDepthFunction(DepthBufferFunction));
|
||||
ErrorHelper.Check("DepthFunc");
|
||||
|
||||
GL.DepthMask(DepthBufferWriteEnable);
|
||||
ErrorHelper.Check("DepthMask");
|
||||
#endregion
|
||||
|
||||
#region Stencil
|
||||
if (StencilEnable)
|
||||
{
|
||||
GL.Enable(EnableCap.StencilTest);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Disable(EnableCap.StencilTest);
|
||||
}
|
||||
ErrorHelper.Check("StencilTest");
|
||||
|
||||
GL.StencilMask(StencilWriteMask);
|
||||
ErrorHelper.Check("StencilMask");
|
||||
|
||||
if (TwoSidedStencilMode)
|
||||
{
|
||||
GL.StencilOpSeparate(StencilFace.Front,
|
||||
TranslateStencilOp(StencilFail),
|
||||
TranslateStencilOp(StencilDepthBufferFail),
|
||||
TranslateStencilOp(StencilPass));
|
||||
ErrorHelper.Check("StencilOpSeparate Front");
|
||||
|
||||
GL.StencilOpSeparate(StencilFace.Back,
|
||||
TranslateStencilOp(CounterClockwiseStencilFail),
|
||||
TranslateStencilOp(CounterClockwiseStencilDepthBufferFail),
|
||||
TranslateStencilOp(CounterClockwiseStencilPass));
|
||||
ErrorHelper.Check("StencilOpSeparate Back");
|
||||
|
||||
GL.StencilFuncSeparate(StencilFace.Front,
|
||||
TranslateStencilFunction(StencilFunction),
|
||||
ReferenceStencil, StencilMask);
|
||||
ErrorHelper.Check("StencilFuncSeparate Front");
|
||||
|
||||
GL.StencilFuncSeparate(StencilFace.Back,
|
||||
TranslateStencilFunction(CounterClockwiseStencilFunction),
|
||||
ReferenceStencil, StencilMask);
|
||||
ErrorHelper.Check("StencilFuncSeparate Back");
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.StencilOp(
|
||||
TranslateStencilOp(StencilFail),
|
||||
TranslateStencilOp(StencilDepthBufferFail),
|
||||
TranslateStencilOp(StencilPass));
|
||||
ErrorHelper.Check("StencilOp");
|
||||
|
||||
GL.StencilFunc(TranslateStencilFunction(StencilFunction),
|
||||
ReferenceStencil, StencilMask);
|
||||
ErrorHelper.Check("StencilFunc");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TranslateStencilOp
|
||||
/// <summary>
|
||||
/// Translate the ANX stencil operation to OpenGL.
|
||||
/// </summary>
|
||||
/// <param name="func">ANX stencil operation.</param>
|
||||
/// <returns>Translated OpenGL stencil operation.</returns>
|
||||
private OpenTK.Graphics.OpenGL.StencilOp TranslateStencilOp(
|
||||
StencilOperation operation)
|
||||
{
|
||||
switch (operation)
|
||||
{
|
||||
default:
|
||||
case StencilOperation.Decrement:
|
||||
return StencilOp.Decr;
|
||||
|
||||
case StencilOperation.DecrementSaturation:
|
||||
return StencilOp.DecrWrap;
|
||||
|
||||
case StencilOperation.Increment:
|
||||
return StencilOp.Incr;
|
||||
|
||||
case StencilOperation.IncrementSaturation:
|
||||
return StencilOp.IncrWrap;
|
||||
|
||||
case StencilOperation.Invert:
|
||||
return StencilOp.Invert;
|
||||
|
||||
case StencilOperation.Keep:
|
||||
return StencilOp.Keep;
|
||||
|
||||
case StencilOperation.Replace:
|
||||
return StencilOp.Replace;
|
||||
|
||||
case StencilOperation.Zero:
|
||||
return StencilOp.Zero;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TranslateDepthFunction
|
||||
/// <summary>
|
||||
/// Translate the ANX compare function to the OpenGL depth function.
|
||||
/// </summary>
|
||||
/// <param name="func">ANX compare function.</param>
|
||||
/// <returns>Translated OpenGL depth function.</returns>
|
||||
private OpenTK.Graphics.OpenGL.DepthFunction TranslateDepthFunction(
|
||||
CompareFunction func)
|
||||
{
|
||||
switch (func)
|
||||
{
|
||||
default:
|
||||
case CompareFunction.Always:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Always;
|
||||
|
||||
case CompareFunction.Equal:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Equal;
|
||||
|
||||
case CompareFunction.Greater:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Greater;
|
||||
|
||||
case CompareFunction.GreaterEqual:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Gequal;
|
||||
|
||||
case CompareFunction.Less:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Less;
|
||||
|
||||
case CompareFunction.LessEqual:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Lequal;
|
||||
|
||||
case CompareFunction.Never:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Never;
|
||||
|
||||
case CompareFunction.NotEqual:
|
||||
return OpenTK.Graphics.OpenGL.DepthFunction.Notequal;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TranslateStencilFunction
|
||||
/// <summary>
|
||||
/// Translate the ANX compare function to the OpenGL stencil function.
|
||||
/// </summary>
|
||||
/// <param name="func">ANX compare function.</param>
|
||||
/// <returns>Translated OpenGL stencil function.</returns>
|
||||
private OpenTK.Graphics.OpenGL.StencilFunction TranslateStencilFunction(
|
||||
CompareFunction func)
|
||||
{
|
||||
switch (func)
|
||||
{
|
||||
default:
|
||||
case CompareFunction.Always:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Always;
|
||||
|
||||
case CompareFunction.Equal:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Equal;
|
||||
|
||||
case CompareFunction.Greater:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Greater;
|
||||
|
||||
case CompareFunction.GreaterEqual:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Gequal;
|
||||
|
||||
case CompareFunction.Less:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Less;
|
||||
|
||||
case CompareFunction.LessEqual:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Lequal;
|
||||
|
||||
case CompareFunction.Never:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Never;
|
||||
|
||||
case CompareFunction.NotEqual:
|
||||
return OpenTK.Graphics.OpenGL.StencilFunction.Notequal;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Release
|
||||
/// <summary>
|
||||
/// Release the depth stencil state.
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
IsBound = false;
|
||||
Current = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose the depth stencil state object.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,298 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.RenderSystem.Windows.GL3.Helpers;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native OpenGL Effect implementation.
|
||||
/// http://wiki.delphigl.com/index.php/Tutorial_glsl
|
||||
/// </summary>
|
||||
public class EffectGL3 : INativeEffect
|
||||
{
|
||||
#region Private
|
||||
private Effect managedEffect;
|
||||
private ShaderData shaderData;
|
||||
private List<EffectParameter> parameters;
|
||||
private List<EffectTechnique> techniques;
|
||||
internal bool IsDisposed;
|
||||
|
||||
internal EffectTechniqueGL3 CurrentTechnique
|
||||
{
|
||||
get
|
||||
{
|
||||
if (managedEffect.CurrentTechnique == null)
|
||||
return null;
|
||||
|
||||
return managedEffect.CurrentTechnique.NativeTechnique as EffectTechniqueGL3;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
#region Techniques
|
||||
public IEnumerable<EffectTechnique> Techniques
|
||||
{
|
||||
get
|
||||
{
|
||||
if (techniques.Count == 0)
|
||||
{
|
||||
Compile();
|
||||
}
|
||||
|
||||
return techniques;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Parameters
|
||||
public IEnumerable<EffectParameter> Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (techniques.Count == 0)
|
||||
{
|
||||
Compile();
|
||||
}
|
||||
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Private helper constructor for the basic initialization.
|
||||
/// </summary>
|
||||
private EffectGL3(Effect setManagedEffect)
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, true);
|
||||
|
||||
parameters = new List<EffectParameter>();
|
||||
techniques = new List<EffectTechnique>();
|
||||
managedEffect = setManagedEffect;
|
||||
}
|
||||
|
||||
~EffectGL3()
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new effect instance of separate streams.
|
||||
/// </summary>
|
||||
/// <param name="vertexShaderByteCode">The vertex shader code.</param>
|
||||
/// <param name="pixelShaderByteCode">The fragment shader code.</param>
|
||||
public EffectGL3(Effect setManagedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
|
||||
: this(setManagedEffect)
|
||||
{
|
||||
// TODO: this is probably not right!
|
||||
throw new NotImplementedException("TODO: implement effect constructor with vertex and fragment streams, check HOWTO...");
|
||||
//CreateShader(ShaderHelper.LoadShaderCode(vertexShaderByteCode),
|
||||
// ShaderHelper.LoadShaderCode(pixelShaderByteCode));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new effect instance of one streams.
|
||||
/// </summary>
|
||||
/// <param name="byteCode">The byte code of the shader.</param>
|
||||
public EffectGL3(Effect setManagedEffect, Stream byteCode)
|
||||
: this(setManagedEffect)
|
||||
{
|
||||
string source = ShaderHelper.LoadShaderCode(byteCode);
|
||||
shaderData = ShaderHelper.ParseShaderCode(source);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RecreateData
|
||||
internal void RecreateData()
|
||||
{
|
||||
Compile();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Compile
|
||||
private void Compile()
|
||||
{
|
||||
parameters.Clear();
|
||||
techniques.Clear();
|
||||
Dictionary<string, int> vertexShaders = new Dictionary<string, int>();
|
||||
Dictionary<string, int> fragmentShaders = new Dictionary<string, int>();
|
||||
List<string> parameterNames = new List<string>();
|
||||
|
||||
#region Compile vertex shaders
|
||||
foreach (string vertexName in shaderData.VertexShaderCodes.Keys)
|
||||
{
|
||||
string vertexSource = shaderData.VertexGlobalCode + shaderData.VertexShaderCodes[vertexName];
|
||||
|
||||
int vertexShader = GL.CreateShader(ShaderType.VertexShader);
|
||||
string vertexError = CompileShader(vertexShader, vertexSource);
|
||||
if (String.IsNullOrEmpty(vertexError) == false)
|
||||
throw new InvalidDataException("Failed to compile the vertex shader '" + vertexName + "' cause of: " +
|
||||
vertexError);
|
||||
|
||||
vertexShaders.Add(vertexName, vertexShader);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Compile fragment shaders
|
||||
foreach (string fragmentName in shaderData.FragmentShaderCodes.Keys)
|
||||
{
|
||||
string fragmentSource = shaderData.FragmentGlobalCode + shaderData.FragmentShaderCodes[fragmentName];
|
||||
|
||||
int fragmentShader = GL.CreateShader(ShaderType.FragmentShader);
|
||||
string fragmentError = CompileShader(fragmentShader, fragmentSource);
|
||||
if (String.IsNullOrEmpty(fragmentError) == false)
|
||||
throw new InvalidDataException("Failed to compile the fragment shader '" + fragmentName + "' cause of: " +
|
||||
fragmentError);
|
||||
|
||||
fragmentShaders.Add(fragmentName, fragmentShader);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Compile programs
|
||||
foreach (string programName in shaderData.Techniques.Keys)
|
||||
{
|
||||
string vertexName = shaderData.Techniques[programName].Key;
|
||||
string fragmentName = shaderData.Techniques[programName].Value;
|
||||
|
||||
int programHandle = GL.CreateProgram();
|
||||
ErrorHelper.Check("CreateProgram");
|
||||
GL.AttachShader(programHandle, vertexShaders[vertexName]);
|
||||
ErrorHelper.Check("AttachShader vertexShader");
|
||||
GL.AttachShader(programHandle, fragmentShaders[fragmentName]);
|
||||
ErrorHelper.Check("AttachShader fragmentShader");
|
||||
GL.LinkProgram(programHandle);
|
||||
|
||||
int result;
|
||||
GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out result);
|
||||
if (result == 0)
|
||||
{
|
||||
string programError;
|
||||
GL.GetProgramInfoLog(programHandle, out programError);
|
||||
throw new InvalidDataException("Failed to link the shader program '" +
|
||||
programName + "' because of: " + programError);
|
||||
}
|
||||
|
||||
EffectTechniqueGL3 technique = new EffectTechniqueGL3(managedEffect, programName, programHandle);
|
||||
techniques.Add(new EffectTechnique(managedEffect, technique));
|
||||
AddParametersFrom(programHandle, parameterNames, technique);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CompileShader
|
||||
private string CompileShader(int shader, string source)
|
||||
{
|
||||
GL.ShaderSource(shader, source);
|
||||
GL.CompileShader(shader);
|
||||
|
||||
int result;
|
||||
GL.GetShader(shader, ShaderParameter.CompileStatus, out result);
|
||||
if (result == 0)
|
||||
{
|
||||
string error = "";
|
||||
GL.GetShaderInfoLog(shader, out error);
|
||||
|
||||
GL.DeleteShader(shader);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddParametersFrom
|
||||
private void AddParametersFrom(int programHandle, List<string> parameterNames,
|
||||
EffectTechniqueGL3 technique)
|
||||
{
|
||||
int uniformCount;
|
||||
GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms,
|
||||
out uniformCount);
|
||||
ErrorHelper.Check("GetProgram ActiveUniforms");
|
||||
|
||||
for (int index = 0; index < uniformCount; index++)
|
||||
{
|
||||
string name = GL.GetActiveUniformName(programHandle, index);
|
||||
ErrorHelper.Check("GetActiveUniformName name=" + name);
|
||||
|
||||
if (parameterNames.Contains(name) == false)
|
||||
{
|
||||
parameterNames.Add(name);
|
||||
int uniformIndex = GL.GetUniformLocation(programHandle, name);
|
||||
ErrorHelper.Check("GetUniformLocation name=" + name +
|
||||
" uniformIndex=" + uniformIndex);
|
||||
parameters.Add(new EffectParameter()
|
||||
{
|
||||
NativeParameter =
|
||||
new EffectParameterGL3(technique, name, uniformIndex),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply
|
||||
public void Apply(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
GL.UseProgram(CurrentTechnique.programHandle);
|
||||
GraphicsDeviceWindowsGL3.activeEffect = this;
|
||||
ErrorHelper.Check("UseProgram");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose the native shader data.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed == false)
|
||||
{
|
||||
IsDisposed = true;
|
||||
DisposeResource();
|
||||
}
|
||||
}
|
||||
|
||||
internal void DisposeResource()
|
||||
{
|
||||
if (GraphicsDeviceWindowsGL3.IsContextCurrent == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (EffectTechnique technique in techniques)
|
||||
{
|
||||
int programHandle =
|
||||
(technique.NativeTechnique as EffectTechniqueGL3).programHandle;
|
||||
|
||||
GL.DeleteProgram(programHandle);
|
||||
ErrorHelper.Check("DeleteProgram");
|
||||
|
||||
int result;
|
||||
GL.GetProgram(programHandle, ProgramParameter.DeleteStatus, out result);
|
||||
if (result == 0)
|
||||
{
|
||||
string deleteError;
|
||||
GL.GetProgramInfoLog(programHandle, out deleteError);
|
||||
throw new Exception("Failed to delete the shader program '" +
|
||||
technique.Name + "' because of: " + deleteError);
|
||||
}
|
||||
}
|
||||
techniques.Clear();
|
||||
parameters.Clear();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,569 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native OpenGL implementation of an effect parameter.
|
||||
/// </summary>
|
||||
public class EffectParameterGL3 : INativeEffectParameter
|
||||
{
|
||||
#region Private
|
||||
private EffectTechniqueGL3 parentTechnique;
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
/// <summary>
|
||||
/// The name of the effect parameter.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The index of the uniform.
|
||||
/// </summary>
|
||||
public int UniformIndex
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a ne effect parameter object.
|
||||
/// </summary>
|
||||
internal EffectParameterGL3(EffectTechniqueGL3 setParentTechnique,
|
||||
string setName, int setUniformIndex)
|
||||
{
|
||||
parentTechnique = setParentTechnique;
|
||||
Name = setName;
|
||||
UniformIndex = setUniformIndex;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue
|
||||
#region SetValue (Matrix)
|
||||
/// <summary>
|
||||
/// Set a matrix value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Matrix value, bool transpose)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
|
||||
OpenTK.Matrix4 matrix = new OpenTK.Matrix4(
|
||||
value.M11, value.M12, value.M13, value.M14,
|
||||
value.M21, value.M22, value.M23, value.M24,
|
||||
value.M31, value.M32, value.M33, value.M34,
|
||||
value.M41, value.M42, value.M43, value.M44);
|
||||
|
||||
GL.UniformMatrix4(UniformIndex, transpose, ref matrix);
|
||||
ErrorHelper.Check("UniformMatrix4");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Matrix[])
|
||||
/// <summary>
|
||||
/// Set a Matrix array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Matrix[] value, bool transpose)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
float[] array = new float[value.Length * 16];
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
array[(index * 16)] = value[index].M11;
|
||||
array[(index * 16) + 1] = value[index].M12;
|
||||
array[(index * 16) + 2] = value[index].M13;
|
||||
array[(index * 16) + 3] = value[index].M14;
|
||||
array[(index * 16) + 4] = value[index].M21;
|
||||
array[(index * 16) + 5] = value[index].M22;
|
||||
array[(index * 16) + 6] = value[index].M23;
|
||||
array[(index * 16) + 7] = value[index].M24;
|
||||
array[(index * 16) + 8] = value[index].M31;
|
||||
array[(index * 16) + 9] = value[index].M32;
|
||||
array[(index * 16) + 10] = value[index].M33;
|
||||
array[(index * 16) + 11] = value[index].M34;
|
||||
array[(index * 16) + 12] = value[index].M41;
|
||||
array[(index * 16) + 13] = value[index].M42;
|
||||
array[(index * 16) + 14] = value[index].M43;
|
||||
array[(index * 16) + 15] = value[index].M44;
|
||||
}
|
||||
GL.UniformMatrix4(UniformIndex, array.Length, transpose, array);
|
||||
ErrorHelper.Check("UniformMatrix4v");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Texture)
|
||||
private Texture textureCache = null;
|
||||
/// <summary>
|
||||
/// Set a texture value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Texture value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
if (textureCache == null ||
|
||||
textureCache != value)
|
||||
{
|
||||
textureCache = value;
|
||||
// TODO: multiple texture units
|
||||
TextureUnit textureUnit = TextureUnit.Texture0;
|
||||
GL.ActiveTexture(textureUnit);
|
||||
ErrorHelper.Check("ActiveTexture");
|
||||
int handle = (value.NativeTexture as Texture2DGL3).NativeHandle;
|
||||
GL.BindTexture(TextureTarget.Texture2D, handle);
|
||||
ErrorHelper.Check("BindTexture");
|
||||
int unitIndex = (int)(textureUnit - TextureUnit.Texture0);
|
||||
GL.Uniform1(UniformIndex, 1, ref unitIndex);
|
||||
ErrorHelper.Check("Uniform1");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (int)
|
||||
/// <summary>
|
||||
/// Set an int value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(int value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform1(UniformIndex, value);
|
||||
ErrorHelper.Check("Uniform1i");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (int[])
|
||||
/// <summary>
|
||||
/// Set an int array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(int[] value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform1(UniformIndex, value.Length, value);
|
||||
ErrorHelper.Check("Uniform1iv");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (float)
|
||||
/// <summary>
|
||||
/// Set a float value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(float value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform1(UniformIndex, value);
|
||||
ErrorHelper.Check("Uniform1f");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (float[])
|
||||
/// <summary>
|
||||
/// Set a float array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(float[] value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform1(UniformIndex, value.Length, value);
|
||||
ErrorHelper.Check("Uniform1fv");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Vector2)
|
||||
/// <summary>
|
||||
/// Set a Vector2 value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Vector2 value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform2(UniformIndex, value.X, value.Y);
|
||||
ErrorHelper.Check("Uniform2f");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Vector2[])
|
||||
/// <summary>
|
||||
/// Set a Vector2 array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Vector2[] value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
float[] array = new float[value.Length * 2];
|
||||
for(int index = 0; index < value.Length; index++)
|
||||
{
|
||||
array[(index * 2)] = value[index].X;
|
||||
array[(index * 2) + 1] = value[index].Y;
|
||||
}
|
||||
GL.Uniform2(UniformIndex, array.Length, array);
|
||||
ErrorHelper.Check("Uniform2fv");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Vector3)
|
||||
/// <summary>
|
||||
/// Set a Vector3 value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Vector3 value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform3(UniformIndex, value.X, value.Y, value.Z);
|
||||
ErrorHelper.Check("Uniform3f");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Vector3[])
|
||||
/// <summary>
|
||||
/// Set a Vector3 array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Vector3[] value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
float[] array = new float[value.Length * 3];
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
array[(index * 3)] = value[index].X;
|
||||
array[(index * 3) + 1] = value[index].Y;
|
||||
array[(index * 3) + 2] = value[index].Z;
|
||||
}
|
||||
GL.Uniform3(UniformIndex, array.Length, array);
|
||||
ErrorHelper.Check("Uniform3fv");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Vector4)
|
||||
/// <summary>
|
||||
/// Set a Vector4 value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Vector4 value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform4(UniformIndex, value.X, value.Y, value.Z, value.W);
|
||||
ErrorHelper.Check("Uniform4f");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Vector4[])
|
||||
/// <summary>
|
||||
/// Set a Vector4 array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Vector4[] value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
float[] array = new float[value.Length * 4];
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
array[(index * 4)] = value[index].X;
|
||||
array[(index * 4) + 1] = value[index].Y;
|
||||
array[(index * 4) + 2] = value[index].Z;
|
||||
array[(index * 4) + 3] = value[index].W;
|
||||
}
|
||||
GL.Uniform4(UniformIndex, array.Length, array);
|
||||
ErrorHelper.Check("Uniform4fv");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (bool)
|
||||
/// <summary>
|
||||
/// Set a bool value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(bool value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform1(UniformIndex, value ? 1 : 0);
|
||||
ErrorHelper.Check("Uniform4f");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (bool[])
|
||||
/// <summary>
|
||||
/// Set a bool array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(bool[] value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
int[] glBooleans = new int[value.Length];
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
glBooleans[index] = value[index] ? 1 : 0;
|
||||
}
|
||||
GL.Uniform1(UniformIndex, value.Length, glBooleans);
|
||||
ErrorHelper.Check("Uniform1iv");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Quaternion)
|
||||
/// <summary>
|
||||
/// Set a Quaternion value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Quaternion value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
GL.Uniform4(UniformIndex, value.X, value.Y, value.Z, value.W);
|
||||
ErrorHelper.Check("Uniform4f");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (Quaternion[])
|
||||
/// <summary>
|
||||
/// Set a Quaternion array value to the effect parameter.
|
||||
/// </summary>
|
||||
/// <param name="value">Value for the parameter</param>
|
||||
public void SetValue(Quaternion[] value)
|
||||
{
|
||||
GL.UseProgram(parentTechnique.programHandle);
|
||||
ErrorHelper.Check("UseProgram");
|
||||
float[] array = new float[value.Length * 4];
|
||||
for (int index = 0; index < value.Length; index++)
|
||||
{
|
||||
array[(index * 4)] = value[index].X;
|
||||
array[(index * 4) + 1] = value[index].Y;
|
||||
array[(index * 4) + 2] = value[index].Z;
|
||||
array[(index * 4) + 3] = value[index].W;
|
||||
}
|
||||
GL.Uniform4(UniformIndex, array.Length, array);
|
||||
ErrorHelper.Check("Uniform4fv");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetValue (string, TODO)
|
||||
public void SetValue(string value)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region GetValue
|
||||
#region GetValueBoolean
|
||||
public bool GetValueBoolean()
|
||||
{
|
||||
int result;
|
||||
GL.GetUniform(parentTechnique.programHandle, UniformIndex, out result);
|
||||
ErrorHelper.Check("GetUniform");
|
||||
return result == 1;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueBooleanArray (TODO)
|
||||
public bool[] GetValueBooleanArray(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueInt32
|
||||
public int GetValueInt32()
|
||||
{
|
||||
int result;
|
||||
GL.GetUniform(parentTechnique.programHandle, UniformIndex, out result);
|
||||
ErrorHelper.Check("GetUniform");
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueInt32Array (TODO)
|
||||
public int[] GetValueInt32Array(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueMatrix (TODO)
|
||||
public Matrix GetValueMatrix()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueMatrixArray (TODO)
|
||||
public Matrix[] GetValueMatrixArray(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueMatrixTranspose (TODO)
|
||||
public Matrix GetValueMatrixTranspose()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueMatrixTransposeArray (TODO)
|
||||
public Matrix[] GetValueMatrixTransposeArray(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueQuaternion (TODO)
|
||||
public Quaternion GetValueQuaternion()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueQuaternionArray (TODO)
|
||||
public Quaternion[] GetValueQuaternionArray(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueSingle
|
||||
public float GetValueSingle()
|
||||
{
|
||||
float result;
|
||||
GL.GetUniform(parentTechnique.programHandle, UniformIndex, out result);
|
||||
ErrorHelper.Check("GetUniform");
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueSingleArray (TODO)
|
||||
public float[] GetValueSingleArray(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueString (TODO)
|
||||
public string GetValueString()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueTexture2D (TODO)
|
||||
public Texture2D GetValueTexture2D()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueTexture3D (TODO)
|
||||
public Texture3D GetValueTexture3D()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueTextureCube (TODO)
|
||||
public TextureCube GetValueTextureCube()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueVector2
|
||||
public Vector2 GetValueVector2()
|
||||
{
|
||||
float[] result = new float[2];
|
||||
unsafe
|
||||
{
|
||||
fixed (float* ptr = &result[0])
|
||||
{
|
||||
GL.GetUniform(parentTechnique.programHandle, UniformIndex, ptr);
|
||||
}
|
||||
}
|
||||
ErrorHelper.Check("GetUniform");
|
||||
return new Vector2(result[0], result[1]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueVector2Array (TODO)
|
||||
public Vector2[] GetValueVector2Array(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueVector3
|
||||
public Vector3 GetValueVector3()
|
||||
{
|
||||
float[] result = new float[3];
|
||||
unsafe
|
||||
{
|
||||
fixed (float* ptr = &result[0])
|
||||
{
|
||||
GL.GetUniform(parentTechnique.programHandle, UniformIndex, ptr);
|
||||
}
|
||||
}
|
||||
ErrorHelper.Check("GetUniform");
|
||||
return new Vector3(result[0], result[1], result[2]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueVector3Array (TODO)
|
||||
public Vector3[] GetValueVector3Array(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueVector4
|
||||
public Vector4 GetValueVector4()
|
||||
{
|
||||
float[] result = new float[4];
|
||||
unsafe
|
||||
{
|
||||
fixed (float* ptr = &result[0])
|
||||
{
|
||||
GL.GetUniform(parentTechnique.programHandle, UniformIndex, ptr);
|
||||
}
|
||||
}
|
||||
ErrorHelper.Check("GetUniform");
|
||||
return new Vector4(result[0], result[1], result[2], result[3]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetValueVector4Array (TODO)
|
||||
public Vector4[] GetValueVector4Array(int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public class EffectPassGL3 : INativeEffectPass
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "p0";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native OpenGL implementation of an effect technique.
|
||||
/// </summary>
|
||||
public class EffectTechniqueGL3 : INativeEffectTechnique
|
||||
{
|
||||
#region Private
|
||||
/// <summary>
|
||||
/// The native shader handle.
|
||||
/// </summary>
|
||||
internal int programHandle;
|
||||
|
||||
/// <summary>
|
||||
/// The active attributes of this technique.
|
||||
/// </summary>
|
||||
internal ShaderAttributeGL3[] activeAttributes;
|
||||
|
||||
/// <summary>
|
||||
/// We currently have only one pass per technique.
|
||||
/// </summary>
|
||||
private EffectPass pass;
|
||||
|
||||
private Effect parentEffect;
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
/// <summary>
|
||||
/// The name of the effect technique.
|
||||
/// </summary>
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The passes of the technique.
|
||||
/// </summary>
|
||||
public IEnumerable<EffectPass> Passes
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return pass;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a ne effect technique object.
|
||||
/// </summary>
|
||||
internal EffectTechniqueGL3(Effect setParentEffect, string setName, int setProgramHandle)
|
||||
{
|
||||
parentEffect = setParentEffect;
|
||||
Name = setName;
|
||||
programHandle = setProgramHandle;
|
||||
|
||||
GetAttributes();
|
||||
|
||||
pass = new EffectPass(parentEffect);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetAttributes
|
||||
private void GetAttributes()
|
||||
{
|
||||
int attributeCount;
|
||||
GL.GetProgram(programHandle, ProgramParameter.ActiveAttributes,
|
||||
out attributeCount);
|
||||
activeAttributes = new ShaderAttributeGL3[attributeCount];
|
||||
for (int index = 0; index < attributeCount; index++)
|
||||
{
|
||||
activeAttributes[index] = new ShaderAttributeGL3(programHandle, index);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using ANX.Framework.NonXNA;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
internal static class ErrorHelper
|
||||
{
|
||||
public static void Check(string extraInformation = "")
|
||||
{
|
||||
ErrorCode code = GL.GetError();
|
||||
if (code != ErrorCode.NoError)
|
||||
{
|
||||
string frameInfo = "";
|
||||
foreach (StackFrame frame in new StackTrace().GetFrames())
|
||||
{
|
||||
MethodBase method = frame.GetMethod();
|
||||
frameInfo += "\n\t" + "at " + method.DeclaringType + "." +
|
||||
method + ":" + frame.GetFileLineNumber();
|
||||
}
|
||||
|
||||
string message = "OpenGL Error '" + code + "' Checked at: '" +
|
||||
extraInformation + "'" + frameInfo;
|
||||
|
||||
Logger.Info(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,458 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.RenderSystem.Windows.GL3.Helpers;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using OpenTK.Platform;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public class GraphicsDeviceWindowsGL3 : INativeGraphicsDevice
|
||||
{
|
||||
#region Constants
|
||||
private const float ColorMultiplier = 1f / 255f;
|
||||
#endregion
|
||||
|
||||
#region Private
|
||||
private GraphicsContext nativeContext;
|
||||
private IWindowInfo nativeWindowInfo;
|
||||
private GraphicsMode graphicsMode;
|
||||
|
||||
private int cachedVersionMinor = -1;
|
||||
private int cachedVersionMajor = -1;
|
||||
|
||||
internal static VertexBufferGL3[] boundVertexBuffers;
|
||||
private static RenderTarget2DGL3[] boundRenderTargets;
|
||||
internal static IndexBufferGL3 boundIndexBuffer;
|
||||
internal static EffectGL3 activeEffect;
|
||||
|
||||
internal static GraphicsDeviceWindowsGL3 Current
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
internal static bool IsContextCurrent
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Current == null || Current.nativeContext == null) ? false : Current.nativeContext.IsCurrent;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
#region VSync
|
||||
public bool VSync
|
||||
{
|
||||
get
|
||||
{
|
||||
return nativeContext.VSync;
|
||||
}
|
||||
set
|
||||
{
|
||||
nativeContext.VSync = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
internal GraphicsDeviceWindowsGL3(PresentationParameters presentationParameters)
|
||||
{
|
||||
Current = this;
|
||||
ResetDevice(presentationParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ResetDevice
|
||||
private void ResetDevice(PresentationParameters presentationParameters)
|
||||
{
|
||||
if (nativeContext != null)
|
||||
Dispose();
|
||||
|
||||
boundVertexBuffers = new VertexBufferGL3[0];
|
||||
boundRenderTargets = new RenderTarget2DGL3[0];
|
||||
boundIndexBuffer = null;
|
||||
activeEffect = null;
|
||||
|
||||
int depth = 0;
|
||||
int stencil = 0;
|
||||
switch (presentationParameters.DepthStencilFormat)
|
||||
{
|
||||
case DepthFormat.None:
|
||||
break;
|
||||
|
||||
case DepthFormat.Depth16:
|
||||
depth = 16;
|
||||
break;
|
||||
|
||||
case DepthFormat.Depth24:
|
||||
depth = 24;
|
||||
break;
|
||||
|
||||
case DepthFormat.Depth24Stencil8:
|
||||
depth = 24;
|
||||
stencil = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
ResizeRenderWindow(presentationParameters);
|
||||
|
||||
var colorFormat = DatatypesMapping.SurfaceToColorFormat(presentationParameters.BackBufferFormat);
|
||||
graphicsMode = new GraphicsMode(colorFormat, depth, stencil, presentationParameters.MultiSampleCount);
|
||||
|
||||
CreateWindowInfo(presentationParameters.DeviceWindowHandle, graphicsMode.Index.Value);
|
||||
|
||||
nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo);
|
||||
nativeContext.MakeCurrent(nativeWindowInfo);
|
||||
nativeContext.LoadAll();
|
||||
|
||||
LogOpenGLInformation();
|
||||
|
||||
GL.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
|
||||
|
||||
GraphicsResourceManager.RecreateAllResources();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LogOpenGLInformation
|
||||
private void LogOpenGLInformation()
|
||||
{
|
||||
string version = GL.GetString(StringName.Version);
|
||||
string vendor = GL.GetString(StringName.Vendor);
|
||||
string renderer = GL.GetString(StringName.Renderer);
|
||||
string shadingLanguageVersion = GL.GetString(StringName.ShadingLanguageVersion);
|
||||
Logger.Info("OpenGL version: " + version + " (" + vendor + " - " + renderer + ")");
|
||||
Logger.Info("GLSL version: " + shadingLanguageVersion);
|
||||
string[] parts = version.Split(new char[] { '.', ' ' });
|
||||
cachedVersionMajor = int.Parse(parts[0]);
|
||||
cachedVersionMinor = int.Parse(parts[1]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateWindowInfo
|
||||
private void CreateWindowInfo(IntPtr windowHandle, IntPtr graphicsModeHandle)
|
||||
{
|
||||
if (OpenTK.Configuration.RunningOnWindows)
|
||||
nativeWindowInfo = Utilities.CreateWindowsWindowInfo(windowHandle);
|
||||
else if (OpenTK.Configuration.RunningOnX11)
|
||||
nativeWindowInfo = LinuxInterop.CreateX11WindowInfo(windowHandle, graphicsModeHandle);
|
||||
else if (OpenTK.Configuration.RunningOnMacOS)
|
||||
nativeWindowInfo = Utilities.CreateMacOSCarbonWindowInfo(windowHandle, false, true);
|
||||
else
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetViewport
|
||||
public void SetViewport(Viewport viewport)
|
||||
{
|
||||
GL.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);
|
||||
ErrorHelper.Check("SetViewport");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Clear
|
||||
private uint? lastClearColor;
|
||||
/// <summary>
|
||||
/// Clear the current screen by the specified clear color.
|
||||
/// </summary>
|
||||
/// <param name="color">Clear color.</param>
|
||||
public void Clear(ref Color color)
|
||||
{
|
||||
uint newClearColor = color.PackedValue;
|
||||
if (lastClearColor.HasValue == false ||
|
||||
lastClearColor != newClearColor)
|
||||
{
|
||||
lastClearColor = newClearColor;
|
||||
GL.ClearColor(color.R * ColorMultiplier, color.G * ColorMultiplier,
|
||||
color.B * ColorMultiplier, color.A * ColorMultiplier);
|
||||
ErrorHelper.Check("ClearColor");
|
||||
}
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
ErrorHelper.Check("Clear");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear the current screen by the specified clear color and options.
|
||||
/// </summary>
|
||||
/// <param name="options">Clear options defining which components
|
||||
/// should be cleared.</param>
|
||||
/// <param name="color">Clear color.</param>
|
||||
/// <param name="depth">Depth value.</param>
|
||||
/// <param name="stencil">Stencil value.</param>
|
||||
public void Clear(ClearOptions options, Vector4 color, float depth,
|
||||
int stencil)
|
||||
{
|
||||
Color anxColor;
|
||||
DatatypesMapping.Convert(ref color, out anxColor);
|
||||
uint newClearColor = anxColor.PackedValue;
|
||||
if (lastClearColor != newClearColor)
|
||||
{
|
||||
lastClearColor = newClearColor;
|
||||
GL.ClearColor(anxColor.R * ColorMultiplier, anxColor.G * ColorMultiplier,
|
||||
anxColor.B * ColorMultiplier, anxColor.A * ColorMultiplier);
|
||||
ErrorHelper.Check("ClearColor");
|
||||
}
|
||||
|
||||
ClearBufferMask mask = (ClearBufferMask)0;
|
||||
if ((options | ClearOptions.Target) == options)
|
||||
{
|
||||
mask |= ClearBufferMask.ColorBufferBit;
|
||||
}
|
||||
if ((options | ClearOptions.Stencil) == options)
|
||||
{
|
||||
mask |= ClearBufferMask.StencilBufferBit;
|
||||
}
|
||||
if ((options | ClearOptions.DepthBuffer) == options)
|
||||
{
|
||||
mask |= ClearBufferMask.DepthBufferBit;
|
||||
}
|
||||
|
||||
GL.ClearDepth(depth);
|
||||
ErrorHelper.Check("ClearDepth");
|
||||
GL.ClearStencil(stencil);
|
||||
ErrorHelper.Check("ClearStencil");
|
||||
GL.Clear(mask);
|
||||
ErrorHelper.Check("Clear");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Present
|
||||
/// <summary>
|
||||
/// Swap the graphics buffers.
|
||||
/// </summary>
|
||||
public void Present()
|
||||
{
|
||||
if (nativeContext != null)
|
||||
{
|
||||
nativeContext.SwapBuffers();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DrawIndexedPrimitives
|
||||
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
|
||||
int startIndex, int primitiveCount)
|
||||
{
|
||||
// TODO: baseVertex, minVertexIndex, numVertices, startIndex
|
||||
DrawElementsType elementsType = boundIndexBuffer.elementSize == IndexElementSize.SixteenBits ?
|
||||
DrawElementsType.UnsignedShort :
|
||||
DrawElementsType.UnsignedInt;
|
||||
|
||||
int count;
|
||||
BeginMode mode = DatatypesMapping.PrimitiveTypeToBeginMode(primitiveType, primitiveCount, out count);
|
||||
|
||||
GL.DrawElements(mode, count, elementsType, 0);
|
||||
ErrorHelper.Check("DrawElements");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DrawInstancedPrimitives (TODO)
|
||||
public void DrawInstancedPrimitives(PrimitiveType primitiveType,
|
||||
int baseVertex, int minVertexIndex, int numVertices, int startIndex,
|
||||
int primitiveCount, int instanceCount)
|
||||
{
|
||||
//GL.DrawArraysInstanced(
|
||||
// DatatypesMapping.PrimitiveTypeToBeginMode(primitiveType),
|
||||
// baseVertex, numVertices, instanceCount);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DrawUserIndexedPrimitives (TODO)
|
||||
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType,
|
||||
T[] vertexData, int vertexOffset, int numVertices, Array indexData,
|
||||
int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration,
|
||||
IndexElementSize indexFormat) where T : struct, IVertexType
|
||||
{
|
||||
//BeginMode mode = DatatypesMapping.PrimitiveTypeToBeginMode(primitiveType);
|
||||
|
||||
//if (indexFormat == IndexElementSize.SixteenBits)
|
||||
//{
|
||||
// ushort[] indices = new ushort[indexData.Length];
|
||||
// indexData.CopyTo(indices, 0);
|
||||
// GL.DrawElements(mode, numVertices, DrawElementsType.UnsignedShort,
|
||||
// indices);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// uint[] indices = new uint[indexData.Length];
|
||||
// indexData.CopyTo(indices, 0);
|
||||
// GL.DrawElements(mode, numVertices, DrawElementsType.UnsignedInt,
|
||||
// indices);
|
||||
//}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DrawUserPrimitives (TODO)
|
||||
public void DrawUserPrimitives<T>(PrimitiveType primitiveType,
|
||||
T[] vertexData, int vertexOffset, int primitiveCount,
|
||||
VertexDeclaration vertexDeclaration) where T : struct, IVertexType
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DrawPrimitives (TODO: check)
|
||||
public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset,
|
||||
int primitiveCount)
|
||||
{
|
||||
int count;
|
||||
BeginMode mode = DatatypesMapping.PrimitiveTypeToBeginMode(primitiveType,
|
||||
primitiveCount, out count);
|
||||
GL.DrawArrays(mode, vertexOffset, count);
|
||||
ErrorHelper.Check("DrawArrays");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetConstantBuffer (TODO)
|
||||
#if XNAEXT
|
||||
public void SetConstantBuffer(int slot, ConstantBuffer constantBuffer)
|
||||
{
|
||||
if (constantBuffer == null)
|
||||
throw new ArgumentNullException("constantBuffer");
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region SetVertexBuffers
|
||||
public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers)
|
||||
{
|
||||
boundVertexBuffers = new VertexBufferGL3[vertexBuffers.Length];
|
||||
for (int index = 0; index < vertexBuffers.Length; index++)
|
||||
{
|
||||
var nativeBuffer = (VertexBufferGL3)vertexBuffers[index].VertexBuffer.NativeVertexBuffer;
|
||||
boundVertexBuffers[index] = nativeBuffer;
|
||||
nativeBuffer.Bind(activeEffect);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetIndexBuffer
|
||||
public void SetIndexBuffer(IndexBuffer indexBuffer)
|
||||
{
|
||||
boundIndexBuffer = (IndexBufferGL3)indexBuffer.NativeIndexBuffer;
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, boundIndexBuffer.BufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ResizeRenderWindow
|
||||
private void ResizeRenderWindow(PresentationParameters presentationParameters)
|
||||
{
|
||||
if (OpenTK.Configuration.RunningOnWindows)
|
||||
{
|
||||
WindowsInterop.ResizeWindow(presentationParameters.DeviceWindowHandle,
|
||||
presentationParameters.BackBufferWidth,
|
||||
presentationParameters.BackBufferHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
LinuxInterop.ResizeWindow(presentationParameters.DeviceWindowHandle,
|
||||
presentationParameters.BackBufferWidth,
|
||||
presentationParameters.BackBufferHeight);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetRenderTargets
|
||||
public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
|
||||
{
|
||||
if (renderTargets == null)
|
||||
{
|
||||
if (boundRenderTargets.Length > 0)
|
||||
{
|
||||
for (int index = 0; index < boundRenderTargets.Length; index++)
|
||||
{
|
||||
boundRenderTargets[index].Unbind();
|
||||
}
|
||||
boundRenderTargets = new RenderTarget2DGL3[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boundRenderTargets = new RenderTarget2DGL3[renderTargets.Length];
|
||||
for (int index = 0; index < renderTargets.Length; index++)
|
||||
{
|
||||
RenderTarget2D renderTarget =
|
||||
renderTargets[index].RenderTarget as RenderTarget2D;
|
||||
RenderTarget2DGL3 nativeRenderTarget =
|
||||
renderTarget.NativeRenderTarget as RenderTarget2DGL3;
|
||||
boundRenderTargets[index] = nativeRenderTarget;
|
||||
|
||||
nativeRenderTarget.Bind();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetBackBufferData (TODO)
|
||||
public void GetBackBufferData<T>(Rectangle? rect, T[] data,
|
||||
int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetBackBufferData<T>(T[] data) where T : struct
|
||||
{
|
||||
//glReadPixels(0, 0, nWidth, nHeight, GL_RGB, GL_UNSIGNED_BYTE, m_pPixelData)
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void GetBackBufferData<T>(T[] data, int startIndex,
|
||||
int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ResizeBuffers
|
||||
public void ResizeBuffers(PresentationParameters presentationParameters)
|
||||
{
|
||||
ResizeRenderWindow(presentationParameters);
|
||||
|
||||
GL.Viewport(0, 0, presentationParameters.BackBufferWidth,
|
||||
presentationParameters.BackBufferHeight);
|
||||
|
||||
ResetDevice(presentationParameters);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public void Dispose()
|
||||
{
|
||||
GraphicsResourceManager.DisposeAllResources();
|
||||
|
||||
lastClearColor = new uint?();
|
||||
boundVertexBuffers = null;
|
||||
boundIndexBuffer = null;
|
||||
activeEffect = null;
|
||||
boundRenderTargets = null;
|
||||
|
||||
if (nativeWindowInfo != null)
|
||||
{
|
||||
nativeWindowInfo.Dispose();
|
||||
nativeWindowInfo = null;
|
||||
}
|
||||
if (nativeContext != null)
|
||||
{
|
||||
nativeContext.Dispose();
|
||||
nativeContext = null;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,299 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework;
|
||||
using ANX.Framework.Graphics;
|
||||
using OpenTK.Graphics;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3.Helpers
|
||||
{
|
||||
internal static class DatatypesMapping
|
||||
{
|
||||
#region Constants
|
||||
public const float ColorMultiplier = 1f / 255f;
|
||||
#endregion
|
||||
|
||||
#region Convert ANX.Color -> OpenTK.Color4
|
||||
public static void Convert(ref Color anxColor, out Color4 otkColor)
|
||||
{
|
||||
otkColor.R = anxColor.R * ColorMultiplier;
|
||||
otkColor.G = anxColor.G * ColorMultiplier;
|
||||
otkColor.B = anxColor.B * ColorMultiplier;
|
||||
otkColor.A = anxColor.A * ColorMultiplier;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Convert OpenTK.Color4 -> ANX.Color
|
||||
public static void Convert(ref Color4 otkColor, out Color anxColor)
|
||||
{
|
||||
byte r = (byte)(otkColor.R * 255);
|
||||
byte g = (byte)(otkColor.G * 255);
|
||||
byte b = (byte)(otkColor.B * 255);
|
||||
byte a = (byte)(otkColor.A * 255);
|
||||
anxColor.packedValue = (uint)(r + (g << 8) + (b << 16) + (a << 24));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Convert ANX.Vector4 -> ANX.Color
|
||||
public static void Convert(ref Vector4 anxVector, out Color anxColor)
|
||||
{
|
||||
byte r = (byte)(anxVector.X * 255);
|
||||
byte g = (byte)(anxVector.Y * 255);
|
||||
byte b = (byte)(anxVector.Z * 255);
|
||||
byte a = (byte)(anxVector.W * 255);
|
||||
anxColor.packedValue = (uint)(r + (g << 8) + (b << 16) + (a << 24));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SurfaceToColorFormat (TODO)
|
||||
/// <summary>
|
||||
/// Translate the XNA surface format to an OpenGL ColorFormat.
|
||||
/// </summary>
|
||||
/// <param name="format">XNA surface format.</param>
|
||||
/// <returns>Translated color format for OpenGL.</returns>
|
||||
public static ColorFormat SurfaceToColorFormat(SurfaceFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
// TODO
|
||||
case SurfaceFormat.Dxt1:
|
||||
case SurfaceFormat.Dxt3:
|
||||
case SurfaceFormat.Dxt5:
|
||||
case SurfaceFormat.HdrBlendable:
|
||||
throw new NotImplementedException("Surface Format '" + format +
|
||||
"' isn't implemented yet!");
|
||||
|
||||
// TODO: CHECK!
|
||||
case SurfaceFormat.NormalizedByte2:
|
||||
return new ColorFormat(8, 8, 0, 0);
|
||||
|
||||
//DONE
|
||||
default:
|
||||
case SurfaceFormat.Color:
|
||||
case SurfaceFormat.NormalizedByte4:
|
||||
return new ColorFormat(8, 8, 8, 8);
|
||||
|
||||
case SurfaceFormat.HalfVector2:
|
||||
return new ColorFormat(16, 16, 0, 0);
|
||||
|
||||
case SurfaceFormat.HalfVector4:
|
||||
return new ColorFormat(16, 16, 16, 16);
|
||||
|
||||
case SurfaceFormat.Bgra4444:
|
||||
return new ColorFormat(4, 4, 4, 4);
|
||||
|
||||
case SurfaceFormat.Bgra5551:
|
||||
return new ColorFormat(5, 5, 5, 1);
|
||||
|
||||
case SurfaceFormat.Alpha8:
|
||||
return new ColorFormat(0, 0, 0, 8);
|
||||
|
||||
case SurfaceFormat.Bgr565:
|
||||
return new ColorFormat(5, 6, 5, 0);
|
||||
|
||||
case SurfaceFormat.Rg32:
|
||||
return new ColorFormat(16, 16, 0, 0);
|
||||
|
||||
case SurfaceFormat.Rgba1010102:
|
||||
return new ColorFormat(10, 10, 10, 2);
|
||||
|
||||
case SurfaceFormat.Rgba64:
|
||||
return new ColorFormat(16, 16, 16, 16);
|
||||
|
||||
case SurfaceFormat.HalfSingle:
|
||||
return new ColorFormat(16, 0, 0, 0);
|
||||
|
||||
case SurfaceFormat.Single:
|
||||
return new ColorFormat(32, 0, 0, 0);
|
||||
|
||||
case SurfaceFormat.Vector2:
|
||||
return new ColorFormat(32, 32, 0, 0);
|
||||
|
||||
case SurfaceFormat.Vector4:
|
||||
return new ColorFormat(32, 32, 32, 32);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SurfaceToPixelInternalFormat (TODO)
|
||||
/// <summary>
|
||||
/// Translate the XNA surface format to an OpenGL PixelInternalFormat.
|
||||
/// </summary>
|
||||
/// <param name="format">XNA surface format.</param>
|
||||
/// <returns>Translated format for OpenGL.</returns>
|
||||
public static PixelInternalFormat SurfaceToPixelInternalFormat(
|
||||
SurfaceFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
// TODO
|
||||
case SurfaceFormat.HdrBlendable:
|
||||
case SurfaceFormat.Bgr565:
|
||||
throw new NotImplementedException("Surface Format '" + format +
|
||||
"' isn't implemented yet!");
|
||||
|
||||
// TODO: CHECK!
|
||||
case SurfaceFormat.NormalizedByte2:
|
||||
return PixelInternalFormat.Rg8;
|
||||
|
||||
default:
|
||||
case SurfaceFormat.Color:
|
||||
case SurfaceFormat.NormalizedByte4:
|
||||
return PixelInternalFormat.Rgba;
|
||||
|
||||
case SurfaceFormat.Dxt1:
|
||||
return PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
|
||||
|
||||
case SurfaceFormat.Dxt3:
|
||||
return PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
|
||||
|
||||
case SurfaceFormat.Dxt5:
|
||||
return PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
|
||||
|
||||
case SurfaceFormat.HalfVector2:
|
||||
return PixelInternalFormat.Rg16;
|
||||
|
||||
case SurfaceFormat.Rgba64:
|
||||
case SurfaceFormat.HalfVector4:
|
||||
return PixelInternalFormat.Rgba16f;
|
||||
|
||||
case SurfaceFormat.Bgra4444:
|
||||
return PixelInternalFormat.Rgba4;
|
||||
|
||||
case SurfaceFormat.Bgra5551:
|
||||
return PixelInternalFormat.Rgb5A1;
|
||||
|
||||
case SurfaceFormat.Alpha8:
|
||||
return PixelInternalFormat.Alpha8;
|
||||
|
||||
case SurfaceFormat.Vector2:
|
||||
case SurfaceFormat.Rg32:
|
||||
return PixelInternalFormat.Rg32f;
|
||||
|
||||
case SurfaceFormat.Rgba1010102:
|
||||
return PixelInternalFormat.Rgb10A2;
|
||||
|
||||
case SurfaceFormat.HalfSingle:
|
||||
return PixelInternalFormat.R16f;
|
||||
|
||||
case SurfaceFormat.Single:
|
||||
return PixelInternalFormat.R32f;
|
||||
|
||||
case SurfaceFormat.Vector4:
|
||||
return PixelInternalFormat.Rgba32f;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PrimitiveTypeToBeginMode
|
||||
/// <summary>
|
||||
/// Translate the XNA PrimitiveType to an OpenGL BeginMode.
|
||||
/// </summary>
|
||||
/// <param name="type">XNA PrimitiveType.</param>
|
||||
/// <returns>Translated BeginMode for OpenGL.</returns>
|
||||
public static BeginMode PrimitiveTypeToBeginMode(PrimitiveType type, int primitiveCount, out int count)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case PrimitiveType.LineList:
|
||||
count = primitiveCount * 2;
|
||||
return BeginMode.Lines;
|
||||
|
||||
case PrimitiveType.LineStrip:
|
||||
count = primitiveCount + 1;
|
||||
return BeginMode.LineStrip;
|
||||
|
||||
default:
|
||||
case PrimitiveType.TriangleList:
|
||||
count = primitiveCount * 3;
|
||||
return BeginMode.Triangles;
|
||||
|
||||
case PrimitiveType.TriangleStrip:
|
||||
count = primitiveCount + 2;
|
||||
return BeginMode.TriangleStrip;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Tests
|
||||
private class Tests
|
||||
{
|
||||
#region TestConvertColorToOtkColor
|
||||
public static void TestConvertColorToOtkColor()
|
||||
{
|
||||
Color anxColor = new Color(1f, 0.5f, 0.75f, 0f);
|
||||
Color4 color;
|
||||
DatatypesMapping.Convert(ref anxColor, out color);
|
||||
Console.WriteLine(color.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TestConvertOtkColorToColor
|
||||
public static void TestConvertOtkColorToColor()
|
||||
{
|
||||
Color4 color = new Color4(1f, 0.5f, 0.75f, 0f);
|
||||
Color anxColor;
|
||||
DatatypesMapping.Convert(ref color, out anxColor);
|
||||
Console.WriteLine(anxColor.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TestConvertVector4ToColor
|
||||
public static void TestConvertVector4ToColor()
|
||||
{
|
||||
Vector4 vector = new Vector4(1f, 0.5f, 0.75f, 0f);
|
||||
Color color;
|
||||
DatatypesMapping.Convert(ref vector, out color);
|
||||
Console.WriteLine(color.ToString());
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TestPrimitiveTypeToBeginMode
|
||||
public static void TestPrimitiveTypeToBeginMode()
|
||||
{
|
||||
PrimitiveType type = PrimitiveType.LineList;
|
||||
int primitiveCount = 10;
|
||||
int count = 0;
|
||||
|
||||
BeginMode result = DatatypesMapping.PrimitiveTypeToBeginMode(type,
|
||||
primitiveCount, out count);
|
||||
AssetValues(result, BeginMode.Lines);
|
||||
AssetValues(count, primitiveCount * 2);
|
||||
|
||||
type = PrimitiveType.LineStrip;
|
||||
result = DatatypesMapping.PrimitiveTypeToBeginMode(type, primitiveCount,
|
||||
out count);
|
||||
AssetValues(result, BeginMode.LineStrip);
|
||||
AssetValues(count, primitiveCount + 1);
|
||||
|
||||
type = PrimitiveType.TriangleList;
|
||||
result = DatatypesMapping.PrimitiveTypeToBeginMode(type, primitiveCount,
|
||||
out count);
|
||||
AssetValues(result, BeginMode.Triangles);
|
||||
AssetValues(count, primitiveCount * 3);
|
||||
|
||||
type = PrimitiveType.TriangleStrip;
|
||||
result = DatatypesMapping.PrimitiveTypeToBeginMode(type, primitiveCount,
|
||||
out count);
|
||||
AssetValues(result, BeginMode.TriangleStrip);
|
||||
AssetValues(count, primitiveCount + 2);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AssetValues
|
||||
private static void AssetValues<T>(T first, T second)
|
||||
{
|
||||
if (first.Equals(second) == false)
|
||||
{
|
||||
throw new Exception("The two values are not equal:\n\t1: " + first +
|
||||
"\n\t2: " + second);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3.Helpers
|
||||
{
|
||||
internal static class GraphicsResourceManager
|
||||
{
|
||||
#region Private
|
||||
private static List<Texture2DGL3> allTextures;
|
||||
|
||||
private static List<EffectGL3> allEffects;
|
||||
|
||||
private static List<VertexBufferGL3> allVertexBuffers;
|
||||
|
||||
private static List<IndexBufferGL3> allIndexBuffers;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
static GraphicsResourceManager()
|
||||
{
|
||||
allTextures = new List<Texture2DGL3>();
|
||||
allEffects = new List<EffectGL3>();
|
||||
allVertexBuffers = new List<VertexBufferGL3>();
|
||||
allIndexBuffers = new List<IndexBufferGL3>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UpdateResource
|
||||
public static void UpdateResource<T>(T resource, bool register)
|
||||
{
|
||||
IList<T> list = null;
|
||||
|
||||
if (typeof(T) == typeof(Texture2DGL3))
|
||||
{
|
||||
list = (IList<T>)allTextures;
|
||||
}
|
||||
else if (typeof(T) == typeof(EffectGL3))
|
||||
{
|
||||
list = (IList<T>)allEffects;
|
||||
}
|
||||
else if (typeof(T) == typeof(VertexBufferGL3))
|
||||
{
|
||||
list = (IList<T>)allVertexBuffers;
|
||||
}
|
||||
else if (typeof(T) == typeof(IndexBufferGL3))
|
||||
{
|
||||
list = (IList<T>)allIndexBuffers;
|
||||
}
|
||||
|
||||
lock (list)
|
||||
{
|
||||
if (register)
|
||||
{
|
||||
list.Add(resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Remove(resource);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DisposeAllResources
|
||||
public static void DisposeAllResources()
|
||||
{
|
||||
#region Textures
|
||||
lock (allTextures)
|
||||
{
|
||||
foreach (Texture2DGL3 texture in allTextures)
|
||||
{
|
||||
if (texture.IsDisposed == false)
|
||||
{
|
||||
texture.DisposeResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Effects
|
||||
lock (allEffects)
|
||||
{
|
||||
foreach (EffectGL3 effect in allEffects)
|
||||
{
|
||||
if (effect.IsDisposed == false)
|
||||
{
|
||||
effect.DisposeResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VertexBuffers
|
||||
lock (allVertexBuffers)
|
||||
{
|
||||
foreach (VertexBufferGL3 buffer in allVertexBuffers)
|
||||
{
|
||||
if (buffer.IsDisposed == false)
|
||||
{
|
||||
buffer.DisposeResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IndexBuffers
|
||||
lock (allIndexBuffers)
|
||||
{
|
||||
foreach (IndexBufferGL3 buffer in allIndexBuffers)
|
||||
{
|
||||
if (buffer.IsDisposed == false)
|
||||
{
|
||||
buffer.DisposeResource();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RecreateAllResources
|
||||
public static void RecreateAllResources()
|
||||
{
|
||||
#region Textures
|
||||
lock (allTextures)
|
||||
{
|
||||
foreach (Texture2DGL3 texture in allTextures)
|
||||
{
|
||||
if (texture.IsDisposed == false)
|
||||
{
|
||||
texture.RecreateData();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Effects
|
||||
lock (allEffects)
|
||||
{
|
||||
foreach (EffectGL3 effect in allEffects)
|
||||
{
|
||||
if (effect.IsDisposed == false)
|
||||
{
|
||||
effect.RecreateData();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region VertexBuffers
|
||||
lock (allVertexBuffers)
|
||||
{
|
||||
foreach (VertexBufferGL3 buffer in allVertexBuffers)
|
||||
{
|
||||
if (buffer.IsDisposed == false)
|
||||
{
|
||||
buffer.RecreateData();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IndexBuffers
|
||||
lock (allIndexBuffers)
|
||||
{
|
||||
foreach (IndexBufferGL3 buffer in allIndexBuffers)
|
||||
{
|
||||
if (buffer.IsDisposed == false)
|
||||
{
|
||||
buffer.RecreateData();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (BlendStateGL3.Current != null)
|
||||
{
|
||||
BlendStateGL3.Current.Apply(null);
|
||||
}
|
||||
if (RasterizerStateGL3.Current != null)
|
||||
{
|
||||
RasterizerStateGL3.Current.Apply(null);
|
||||
}
|
||||
if (DepthStencilStateGL3.Current != null)
|
||||
{
|
||||
DepthStencilStateGL3.Current.Apply(null);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,118 +0,0 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using OpenTK.Platform;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3.Helpers
|
||||
{
|
||||
internal static class LinuxInterop
|
||||
{
|
||||
#region XVisualInfo (Helper struct)
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct XVisualInfo
|
||||
{
|
||||
public IntPtr Visual;
|
||||
public IntPtr VisualID;
|
||||
public int Screen;
|
||||
public int Depth;
|
||||
public int Class;
|
||||
public long RedMask;
|
||||
public long GreenMask;
|
||||
public long blueMask;
|
||||
public int ColormapSize;
|
||||
public int BitsPerRgb;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("id ({0}), screen ({1}), depth ({2}), class ({3})",
|
||||
VisualID, Screen, Depth, Class);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Invokes
|
||||
[DllImport("libX11")]
|
||||
private static extern IntPtr XCreateColormap(IntPtr display, IntPtr window,
|
||||
IntPtr visual, int alloc);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XGetVisualInfo")]
|
||||
private static extern IntPtr XGetVisualInfoInternal(IntPtr display,
|
||||
IntPtr vinfo_mask, ref XVisualInfo template, out int nitems);
|
||||
|
||||
[DllImport("libX11")]
|
||||
private static extern int XPending(IntPtr diplay);
|
||||
|
||||
[DllImport("libX11")]
|
||||
private static extern void XResizeWindow(IntPtr display, IntPtr window,
|
||||
int width, int height);
|
||||
#endregion
|
||||
|
||||
#region GetStaticFieldValue
|
||||
private static object GetStaticFieldValue(Type type, string fieldName)
|
||||
{
|
||||
return type.GetField(fieldName,
|
||||
BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetStaticFieldValue
|
||||
private static void SetStaticFieldValue(Type type, string fieldName,
|
||||
object value)
|
||||
{
|
||||
type.GetField(fieldName,
|
||||
BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateX11WindowInfo
|
||||
public static IWindowInfo CreateX11WindowInfo(IntPtr windowHandle,
|
||||
IntPtr graphicsModeHandle)
|
||||
{
|
||||
// Use reflection to retrieve the necessary values from Mono's
|
||||
// Windows.Forms implementation.
|
||||
Type xplatui = Type.GetType(
|
||||
"System.Windows.Forms.XplatUIX11, System.Windows.Forms");
|
||||
if (xplatui == null)
|
||||
{
|
||||
throw new PlatformNotSupportedException(
|
||||
"System.Windows.Forms.XplatUIX11 missing. Unsupported platform " +
|
||||
"or Mono runtime version, aborting.");
|
||||
}
|
||||
|
||||
// get the required handles from the X11 API.
|
||||
IntPtr display = (IntPtr)GetStaticFieldValue(xplatui, "DisplayHandle");
|
||||
IntPtr rootWindow = (IntPtr)GetStaticFieldValue(xplatui, "RootWindow");
|
||||
int screen = (int)GetStaticFieldValue(xplatui, "ScreenNo");
|
||||
|
||||
// get the XVisualInfo for this GraphicsMode
|
||||
XVisualInfo info = new XVisualInfo()
|
||||
{
|
||||
VisualID = graphicsModeHandle,
|
||||
};
|
||||
int dummy;
|
||||
IntPtr infoPtr = XGetVisualInfoInternal(display,
|
||||
(IntPtr)1 /* VisualInfoMask.ID */, ref info, out dummy);
|
||||
info = (XVisualInfo)Marshal.PtrToStructure(infoPtr, typeof(XVisualInfo));
|
||||
|
||||
// set the X11 colormap.
|
||||
SetStaticFieldValue(xplatui, "CustomVisual", info.Visual);
|
||||
SetStaticFieldValue(xplatui, "CustomColormap", XCreateColormap(display, rootWindow, info.Visual, 0));
|
||||
|
||||
return Utilities.CreateX11WindowInfo(display, screen, windowHandle,
|
||||
rootWindow, infoPtr);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ResizeWindow
|
||||
public static void ResizeWindow(IntPtr windowHandle, int backBufferWidth,
|
||||
int backBufferHeight)
|
||||
{
|
||||
XResizeWindow(IntPtr.Zero, windowHandle, backBufferWidth, backBufferHeight);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3.Helpers
|
||||
{
|
||||
internal static class WindowsInterop
|
||||
{
|
||||
#region RECT (Helper struct)
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct RECT
|
||||
{
|
||||
/// <summary>
|
||||
/// X position of upper-left corner.
|
||||
/// </summary>
|
||||
public int Left;
|
||||
/// <summary>
|
||||
/// Y position of upper-left corner.
|
||||
/// </summary>
|
||||
public int Top;
|
||||
/// <summary>
|
||||
/// X position of lower-right corner.
|
||||
/// </summary>
|
||||
public int Right;
|
||||
/// <summary>
|
||||
/// Y position of lower-right corner.
|
||||
/// </summary>
|
||||
public int Bottom;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Invokes
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,
|
||||
int x, int y, int width, int height, uint uFlags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
|
||||
#endregion
|
||||
|
||||
#region ResizeWindow
|
||||
public static void ResizeWindow(IntPtr windowHandle, int backBufferWidth,
|
||||
int backBufferHeight)
|
||||
{
|
||||
RECT windowRect;
|
||||
RECT clientRect;
|
||||
if (GetWindowRect(windowHandle, out windowRect) &&
|
||||
GetClientRect(windowHandle, out clientRect))
|
||||
{
|
||||
int width = backBufferWidth + (windowRect.Right - windowRect.Left) -
|
||||
clientRect.Right;
|
||||
int height = backBufferHeight + (windowRect.Bottom - windowRect.Top) -
|
||||
clientRect.Bottom;
|
||||
|
||||
SetWindowPos(windowHandle, IntPtr.Zero, windowRect.Left, windowRect.Top,
|
||||
width, height, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,264 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using ANX.RenderSystem.Windows.GL3.Helpers;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native OpenGL implementation of a Index Buffer.
|
||||
/// </summary>
|
||||
public class IndexBufferGL3 : INativeIndexBuffer
|
||||
{
|
||||
#region Private
|
||||
private IndexBuffer managedBuffer;
|
||||
|
||||
private int bufferHandle;
|
||||
/// <summary>
|
||||
/// Native index buffer handle.
|
||||
/// </summary>
|
||||
internal int BufferHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
return bufferHandle;
|
||||
}
|
||||
}
|
||||
|
||||
private int indexCount;
|
||||
|
||||
internal IndexElementSize elementSize;
|
||||
|
||||
private BufferUsage usage;
|
||||
|
||||
private BufferUsageHint usageHint;
|
||||
|
||||
internal bool IsDisposed;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a new Index Buffer object.
|
||||
/// </summary>
|
||||
internal IndexBufferGL3(IndexBuffer setManagedBuffer,
|
||||
IndexElementSize setElementSize, int setIndexCount, BufferUsage setUsage)
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, true);
|
||||
|
||||
managedBuffer = setManagedBuffer;
|
||||
indexCount = setIndexCount;
|
||||
elementSize = setElementSize;
|
||||
usage = setUsage;
|
||||
|
||||
bool isDynamicBuffer = managedBuffer is DynamicIndexBuffer;
|
||||
|
||||
usageHint = isDynamicBuffer ?
|
||||
BufferUsageHint.DynamicDraw :
|
||||
BufferUsageHint.StaticDraw;
|
||||
|
||||
CreateBuffer();
|
||||
}
|
||||
|
||||
~IndexBufferGL3()
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateBuffer
|
||||
private void CreateBuffer()
|
||||
{
|
||||
GL.GenBuffers(1, out bufferHandle);
|
||||
ErrorHelper.Check("GenBuffers");
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
int size = indexCount *
|
||||
(elementSize == IndexElementSize.SixteenBits ? 16 : 32);
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)size, IntPtr.Zero,
|
||||
usageHint);
|
||||
ErrorHelper.Check("BufferData");
|
||||
|
||||
int setSize;
|
||||
GL.GetBufferParameter(BufferTarget.ElementArrayBuffer,
|
||||
BufferParameterName.BufferSize, out setSize);
|
||||
if (setSize != size)
|
||||
{
|
||||
throw new Exception("Failed to set the vertexBuffer data. DataSize=" +
|
||||
size + " SetSize=" + setSize);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RecreateData
|
||||
internal void RecreateData()
|
||||
{
|
||||
CreateBuffer();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data)
|
||||
where T : struct
|
||||
{
|
||||
BufferData(data, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data,
|
||||
int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
if (startIndex != 0 ||
|
||||
elementCount != data.Length)
|
||||
{
|
||||
T[] subArray = new T[elementCount];
|
||||
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||
BufferData(subArray, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferData(data, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes,
|
||||
T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
if (startIndex != 0 ||
|
||||
elementCount != data.Length)
|
||||
{
|
||||
T[] subArray = new T[elementCount];
|
||||
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||
BufferData(subArray, offsetInBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferData(data, offsetInBytes);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BufferData (private helper)
|
||||
private void BufferData<T>(T[] data, int offset) where T : struct
|
||||
{
|
||||
int size = (elementSize == IndexElementSize.SixteenBits ?
|
||||
2 : 4) * data.Length;
|
||||
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
|
||||
if (offset == 0)
|
||||
{
|
||||
GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)size, data,
|
||||
usageHint);
|
||||
ErrorHelper.Check("BufferData size=" + size);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.BufferSubData(BufferTarget.ElementArrayBuffer, (IntPtr)offset,
|
||||
(IntPtr)size, data);
|
||||
ErrorHelper.Check("BufferSubData offset=" + offset + " size=" + size);
|
||||
}
|
||||
|
||||
int setSize;
|
||||
GL.GetBufferParameter(BufferTarget.ElementArrayBuffer,
|
||||
BufferParameterName.BufferSize, out setSize);
|
||||
if (setSize != size)
|
||||
{
|
||||
throw new Exception("Failed to set the indexBuffer data. DataSize=" +
|
||||
size + " SetSize=" + setSize);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
BufferData(data, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount)
|
||||
where T : struct
|
||||
{
|
||||
if (startIndex != 0 ||
|
||||
elementCount != data.Length)
|
||||
{
|
||||
T[] subArray = new T[elementCount];
|
||||
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||
BufferData(subArray, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferData(data, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(int offsetInBytes, T[] data, int startIndex,
|
||||
int elementCount) where T : struct
|
||||
{
|
||||
if (startIndex != 0 ||
|
||||
elementCount != data.Length)
|
||||
{
|
||||
T[] subArray = new T[elementCount];
|
||||
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||
BufferData(subArray, offsetInBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferData(data, offsetInBytes);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetBufferData (private helper)
|
||||
private void GetBufferData<T>(T[] data, int offset) where T : struct
|
||||
{
|
||||
int size = (elementSize == IndexElementSize.SixteenBits ?
|
||||
2 : 4) * data.Length;
|
||||
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
|
||||
GL.GetBufferSubData(BufferTarget.ElementArrayBuffer, (IntPtr)offset,
|
||||
(IntPtr)size, data);
|
||||
ErrorHelper.Check("GetBufferSubData");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose the native index buffer data.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed == false)
|
||||
{
|
||||
IsDisposed = true;
|
||||
DisposeResource();
|
||||
}
|
||||
}
|
||||
|
||||
internal void DisposeResource()
|
||||
{
|
||||
if (bufferHandle != -1 &&
|
||||
GraphicsDeviceWindowsGL3.IsContextCurrent)
|
||||
{
|
||||
GL.DeleteBuffers(1, ref bufferHandle);
|
||||
ErrorHelper.Check("DeleteBuffers");
|
||||
bufferHandle = -1;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
[PercentageComplete(100)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
[Developer("AstrorEnales")]
|
||||
public class OcclusionQueryGL3 : IOcclusionQuery
|
||||
{
|
||||
private uint[] handle;
|
||||
|
||||
#region Public
|
||||
public bool IsComplete
|
||||
{
|
||||
get
|
||||
{
|
||||
int state;
|
||||
GL.GetQueryObject(handle[0], GetQueryObjectParam.QueryResultAvailable, out state);
|
||||
return state != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int PixelCount
|
||||
{
|
||||
get
|
||||
{
|
||||
int result;
|
||||
GL.GetQueryObject(handle[0], GetQueryObjectParam.QueryResult, out result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public OcclusionQueryGL3()
|
||||
{
|
||||
handle = new uint[1];
|
||||
GL.GenQueries(1, handle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Begin
|
||||
public void Begin()
|
||||
{
|
||||
//GLCore.ColorMask(false, false, false, false);
|
||||
//GLCore.DepthMask(false);
|
||||
GL.BeginQuery(QueryTarget.SamplesPassed, handle[0]);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region End
|
||||
public void End()
|
||||
{
|
||||
GL.EndQuery(QueryTarget.SamplesPassed);
|
||||
//GLCore.DepthMask(true);
|
||||
//GLCore.ColorMask(true, true, true, true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public void Dispose()
|
||||
{
|
||||
GL.DeleteQueries(1, handle);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// Allgemeine Informationen über eine Assembly werden über die folgenden
|
||||
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
|
||||
// die mit einer Assembly verknüpft sind.
|
||||
[assembly: AssemblyTitle("ANX.RenderSystem.Windows.GL3")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("ANX.Framework Team")]
|
||||
[assembly: AssemblyProduct("ANX.RenderSystem.Windows.GL3")]
|
||||
[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011 - 2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
|
||||
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
|
||||
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
|
||||
[assembly: Guid("14d07c57-8b86-4f6e-bacb-69f65aba5633")]
|
||||
|
||||
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
|
||||
//
|
||||
// Hauptversion
|
||||
// Nebenversion
|
||||
// Buildnummer
|
||||
// Revision
|
||||
//
|
||||
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
|
||||
// übernehmen, indem Sie "*" eingeben:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.5.11.0")]
|
||||
[assembly: AssemblyFileVersion("0.5.11.0")]
|
||||
|
||||
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]
|
@ -1,218 +0,0 @@
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native Rasterizer State object for OpenGL.
|
||||
/// <para />
|
||||
/// Basically this is a wrapper class for setting the different values all
|
||||
/// at once, because OpenGL has no State objects like DirectX.
|
||||
/// </summary>
|
||||
[PercentageComplete(100)]
|
||||
[TestStateAttribute(TestStateAttribute.TestState.Untested)]
|
||||
public class RasterizerStateGL3 : INativeRasterizerState
|
||||
{
|
||||
#region Private
|
||||
internal static RasterizerStateGL3 Current
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
#region IsBound
|
||||
/// <summary>
|
||||
/// Flag if the state object is bound to the device.
|
||||
/// </summary>
|
||||
public bool IsBound
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CullMode
|
||||
/// <summary>
|
||||
/// The cull mode of the state object.
|
||||
/// </summary>
|
||||
public CullMode CullMode
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ScissorTestEnable
|
||||
/// <summary>
|
||||
/// Flag if the state object has scissor test enabled.
|
||||
/// </summary>
|
||||
public bool ScissorTestEnable
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region FillMode
|
||||
/// <summary>
|
||||
/// The fill mode of the state object.
|
||||
/// </summary>
|
||||
public FillMode FillMode
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SlopeScaleDepthBias
|
||||
/// <summary>
|
||||
/// The SlopeScaleDepthBias of the state object.
|
||||
/// </summary>
|
||||
public float SlopeScaleDepthBias
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DepthBias
|
||||
/// <summary>
|
||||
/// The depth bias of the state object.
|
||||
/// </summary>
|
||||
public float DepthBias
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MultiSampleAntiAlias
|
||||
/// <summary>
|
||||
/// Flag if the state object has MSAA enabled.
|
||||
/// </summary>
|
||||
public bool MultiSampleAntiAlias
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a new rasterizer state object.
|
||||
/// </summary>
|
||||
internal RasterizerStateGL3()
|
||||
{
|
||||
IsBound = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply
|
||||
/// <summary>
|
||||
/// Apply the rasterizer state to the graphics device.
|
||||
/// </summary>
|
||||
/// <param name="graphicsDevice">The current graphics device.</param>
|
||||
public void Apply(GraphicsDevice graphicsDevice)
|
||||
{
|
||||
IsBound = true;
|
||||
Current = this;
|
||||
|
||||
#region Cull Mode
|
||||
GL.FrontFace(FrontFaceDirection.Cw);
|
||||
ErrorHelper.Check("FrontFace");
|
||||
if (CullMode == CullMode.None)
|
||||
{
|
||||
GL.Disable(EnableCap.CullFace);
|
||||
GL.CullFace(CullFaceMode.FrontAndBack);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Enable(EnableCap.CullFace);
|
||||
GL.CullFace(CullMode == CullMode.None ?
|
||||
CullFaceMode.FrontAndBack :
|
||||
CullMode == CullMode.CullClockwiseFace ?
|
||||
CullFaceMode.Front :
|
||||
CullFaceMode.Back);
|
||||
}
|
||||
ErrorHelper.Check("Set CullMode");
|
||||
#endregion
|
||||
|
||||
GL.PolygonMode(MaterialFace.FrontAndBack,
|
||||
FillMode == FillMode.WireFrame ? PolygonMode.Line : PolygonMode.Fill);
|
||||
ErrorHelper.Check("PolygonMode");
|
||||
|
||||
#region ScissorTestEnable
|
||||
if (ScissorTestEnable)
|
||||
{
|
||||
GL.Enable(EnableCap.ScissorTest);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Disable(EnableCap.ScissorTest);
|
||||
}
|
||||
ErrorHelper.Check("Set ScissorTest");
|
||||
#endregion
|
||||
|
||||
#region DepthBias / SlopeScaleDepthBias (TODO: test!)
|
||||
// NOTE: http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml
|
||||
|
||||
// Good article about difference between OpenGL and DirectX concerning
|
||||
// Depth Bias: http://aras-p.info/blog/2008/06/12/depth-bias-and-the-power-of-deceiving-yourself/
|
||||
|
||||
if (DepthBias != 0f &&
|
||||
SlopeScaleDepthBias != 0f)
|
||||
{
|
||||
GL.Enable(EnableCap.PolygonOffsetFill);
|
||||
GL.PolygonOffset(SlopeScaleDepthBias, DepthBias);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Disable(EnableCap.PolygonOffsetFill);
|
||||
}
|
||||
ErrorHelper.Check("Set DepthBias");
|
||||
#endregion
|
||||
|
||||
#region MultiSampleAntiAlias
|
||||
if (MultiSampleAntiAlias)
|
||||
{
|
||||
GL.Enable(EnableCap.Multisample);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.Disable(EnableCap.Multisample);
|
||||
}
|
||||
ErrorHelper.Check("Set Multisample");
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Release
|
||||
/// <summary>
|
||||
/// Release the rasterizer state.
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
IsBound = false;
|
||||
Current = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose the rasterizer state object.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using ANX.RenderSystem.Windows.GL3.Helpers;
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public class RenderTarget2DGL3 : Texture2DGL3, INativeRenderTarget2D
|
||||
{
|
||||
#region Private
|
||||
private int framebufferHandle;
|
||||
private int renderbufferHandle;
|
||||
|
||||
private bool generateMipmaps;
|
||||
#endregion
|
||||
|
||||
// TODO: usage, preferredMultiSampleCount
|
||||
#region Constructor
|
||||
public RenderTarget2DGL3(int width, int height, bool mipMap,
|
||||
SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat,
|
||||
int preferredMultiSampleCount, RenderTargetUsage usage)
|
||||
: base()
|
||||
{
|
||||
generateMipmaps = mipMap;
|
||||
PixelInternalFormat nativeFormat =
|
||||
DatatypesMapping.SurfaceToPixelInternalFormat(preferredFormat);
|
||||
|
||||
#region Image creation
|
||||
NativeHandle = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureMagFilter, (int)All.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureWrapS, (int)All.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureWrapT, (int)All.ClampToEdge);
|
||||
if (generateMipmaps)
|
||||
{
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.GenerateMipmap, 1);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureMinFilter, (int)All.LinearMipmapLinear);
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureMinFilter, (int)All.Linear);
|
||||
}
|
||||
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, nativeFormat,
|
||||
width, height, 0, (PixelFormat)nativeFormat, PixelType.UnsignedByte,
|
||||
IntPtr.Zero);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
#endregion
|
||||
|
||||
// create a renderbuffer object to store depth info
|
||||
GL.GenRenderbuffers(1, out renderbufferHandle);
|
||||
GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, renderbufferHandle);
|
||||
GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer,
|
||||
DepthFormatConversion(preferredDepthFormat), width, height);
|
||||
GL.BindRenderbuffer(RenderbufferTarget.RenderbufferExt, 0);
|
||||
|
||||
// create a framebuffer object
|
||||
GL.GenFramebuffers(1, out framebufferHandle);
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebufferHandle);
|
||||
|
||||
// attach the texture to FBO color attachment point
|
||||
GL.FramebufferTexture2D(FramebufferTarget.Framebuffer,
|
||||
FramebufferAttachment.ColorAttachment0, TextureTarget.Texture2D,
|
||||
NativeHandle, 0);
|
||||
|
||||
// attach the renderbuffer to depth attachment point
|
||||
GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer,
|
||||
FramebufferAttachment.DepthAttachment,
|
||||
RenderbufferTarget.Renderbuffer, renderbufferHandle);
|
||||
|
||||
// check FBO status
|
||||
FramebufferErrorCode status = GL.CheckFramebufferStatus(
|
||||
FramebufferTarget.Framebuffer);
|
||||
if (status != FramebufferErrorCode.FramebufferComplete)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Failed to create the render target! Error=" + status);
|
||||
}
|
||||
|
||||
// switch back to window-system-provided framebuffer
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DepthFormatConversion
|
||||
private RenderbufferStorage DepthFormatConversion(DepthFormat depthFormat)
|
||||
{
|
||||
switch(depthFormat)
|
||||
{
|
||||
default:
|
||||
case DepthFormat.None:
|
||||
// TODO
|
||||
return RenderbufferStorage.DepthComponent16;
|
||||
//return (RenderbufferStorage)All.DepthComponent;
|
||||
|
||||
case DepthFormat.Depth16:
|
||||
return RenderbufferStorage.DepthComponent16;
|
||||
|
||||
case DepthFormat.Depth24:
|
||||
return RenderbufferStorage.DepthComponent24;
|
||||
|
||||
case DepthFormat.Depth24Stencil8:
|
||||
return RenderbufferStorage.DepthComponent32;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Bind
|
||||
public void Bind()
|
||||
{
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, framebufferHandle);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Unbind
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
|
||||
if (generateMipmaps)
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
GL.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
GL.DeleteFramebuffers(1, ref framebufferHandle);
|
||||
GL.DeleteRenderbuffers(1, ref renderbufferHandle);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,139 +0,0 @@
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.NonXNA.Development;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native Sampler State object for OpenGL.
|
||||
/// <para />
|
||||
/// Basically this is a wrapper class for setting the different values all
|
||||
/// at once, because OpenGL has no State objects like DirectX.
|
||||
/// <para />
|
||||
/// Info for OpenGL filter states:
|
||||
/// http://gregs-blog.com/2008/01/17/opengl-texture-filter-parameters-explained/
|
||||
///
|
||||
/// Info for OGL 3.3 sampler objects (sadly not implemented in OpenTK yet):
|
||||
/// http://www.sinanc.org/blog/?p=215
|
||||
/// </summary>
|
||||
[PercentageComplete(10)]
|
||||
[TestState(TestStateAttribute.TestState.Untested)]
|
||||
public class SamplerStateGL3 : INativeSamplerState
|
||||
{
|
||||
#region Public
|
||||
#region IsBound
|
||||
/// <summary>
|
||||
/// Flag if the state object is bound to the device.
|
||||
/// </summary>
|
||||
public bool IsBound
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddressU
|
||||
public TextureAddressMode AddressU
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddressV
|
||||
public TextureAddressMode AddressV
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region AddressW
|
||||
public TextureAddressMode AddressW
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Filter
|
||||
public TextureFilter Filter
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MaxAnisotropy
|
||||
public int MaxAnisotropy
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MaxMipLevel
|
||||
public int MaxMipLevel
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MipMapLevelOfDetailBias
|
||||
public float MipMapLevelOfDetailBias
|
||||
{
|
||||
set;
|
||||
private get;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a new sampler state object.
|
||||
/// </summary>
|
||||
internal SamplerStateGL3()
|
||||
{
|
||||
IsBound = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Apply
|
||||
/// <summary>
|
||||
/// Apply the sampler state.
|
||||
/// </summary>
|
||||
/// <param name="graphicsDevice">Graphics device.</param>
|
||||
/// <param name="index">The index of which sampler should be modified.</param>
|
||||
public void Apply(GraphicsDevice graphicsDevice, int index)
|
||||
{
|
||||
IsBound = true;
|
||||
|
||||
// TODO: set stuff
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Release
|
||||
/// <summary>
|
||||
/// Release the sampler state.
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
IsBound = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose the sampler state object.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
using System;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using ANX.Framework.Graphics;
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public struct ShaderAttributeGL3
|
||||
{
|
||||
#region Public
|
||||
public string Name;
|
||||
public int Location;
|
||||
public int Size;
|
||||
public ActiveAttribType Type;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
public ShaderAttributeGL3(int programHandle, int index)
|
||||
{
|
||||
Name = GL.GetActiveAttrib(programHandle, index, out Size, out Type);
|
||||
Location = GL.GetAttribLocation(programHandle, Name);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Bind
|
||||
public void Bind(VertexElementUsage usage, int stride, int offset)
|
||||
{
|
||||
GL.EnableVertexAttribArray(Location);
|
||||
ErrorHelper.Check("Failed to bind shader attribute " + Name);
|
||||
|
||||
int size = 0;
|
||||
VertexAttribPointerType type = VertexAttribPointerType.Float;
|
||||
bool normalized = false;
|
||||
|
||||
switch (usage)
|
||||
{
|
||||
case VertexElementUsage.Binormal:
|
||||
case VertexElementUsage.Normal:
|
||||
case VertexElementUsage.Tangent:
|
||||
case VertexElementUsage.BlendIndices:
|
||||
case VertexElementUsage.BlendWeight:
|
||||
case VertexElementUsage.Position:
|
||||
size = 3;
|
||||
break;
|
||||
|
||||
case VertexElementUsage.Color:
|
||||
size = 4;
|
||||
type = VertexAttribPointerType.UnsignedByte;
|
||||
normalized = true;
|
||||
break;
|
||||
|
||||
case VertexElementUsage.TextureCoordinate:
|
||||
size = 2;
|
||||
break;
|
||||
|
||||
case VertexElementUsage.Fog:
|
||||
case VertexElementUsage.PointSize:
|
||||
case VertexElementUsage.TessellateFactor:
|
||||
size = 1;
|
||||
break;
|
||||
|
||||
// TODO
|
||||
case VertexElementUsage.Depth:
|
||||
case VertexElementUsage.Sample:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
GL.VertexAttribPointer(Location, size, type, normalized, stride, (IntPtr)offset);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ToString
|
||||
public override string ToString()
|
||||
{
|
||||
return "ShaderAttribute{Name: " + Name +
|
||||
", Location: " + Location +
|
||||
", Size: " + Size +
|
||||
", Type: " + Type + "}";
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,437 +0,0 @@
|
||||
using System;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.Framework.Windows.GL3
|
||||
{
|
||||
internal static class ShaderByteCode
|
||||
{
|
||||
#region SpriteBatchShader
|
||||
internal static byte[] SpriteBatchByteCode = new byte[]
|
||||
{
|
||||
187, 004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 123, 117,
|
||||
110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116,
|
||||
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116,
|
||||
116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111,
|
||||
115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099,
|
||||
052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
|
||||
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105,
|
||||
110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118,
|
||||
101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
|
||||
111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040,
|
||||
032, 041, 123, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061,
|
||||
077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109,
|
||||
042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120,
|
||||
067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 125, 125,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034,
|
||||
123, 117, 110, 105, 102, 111, 114, 109, 032, 115, 097, 109, 112, 108, 101,
|
||||
114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 118, 097, 114,
|
||||
121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103,
|
||||
032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105,
|
||||
110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108,
|
||||
111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101,
|
||||
120, 116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105,
|
||||
113, 117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032,
|
||||
034, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, 105, 113, 117,
|
||||
101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 083, 112, 114, 105,
|
||||
116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116,
|
||||
101, 070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114,
|
||||
034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104, 093, 184, 253, 199,
|
||||
246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094,
|
||||
003, 189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172,
|
||||
146, 241, 173, 160, 182, 034, 092, 221, 158, 045, 049, 229, 144, 171, 015,
|
||||
022, 089, 025, 248, 163, 175, 081
|
||||
};
|
||||
#endregion //SpriteBatchShader
|
||||
|
||||
#region AlphaTestEffectShader
|
||||
internal static byte[] AlphaTestEffectByteCode = new byte[]
|
||||
{
|
||||
187, 004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 123, 117,
|
||||
110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116,
|
||||
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116,
|
||||
116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111,
|
||||
115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099,
|
||||
052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
|
||||
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105,
|
||||
110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118,
|
||||
101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
|
||||
111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040,
|
||||
032, 041, 123, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061,
|
||||
077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109,
|
||||
042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120,
|
||||
067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 125, 125,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034,
|
||||
123, 117, 110, 105, 102, 111, 114, 109, 032, 115, 097, 109, 112, 108, 101,
|
||||
114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 118, 097, 114,
|
||||
121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103,
|
||||
032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105,
|
||||
110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108,
|
||||
111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101,
|
||||
120, 116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105,
|
||||
113, 117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032,
|
||||
034, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, 105, 113, 117,
|
||||
101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 083, 112, 114, 105,
|
||||
116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116,
|
||||
101, 070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114,
|
||||
034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104, 093, 184, 253, 199,
|
||||
246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094,
|
||||
003, 189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172,
|
||||
146, 241, 173, 160, 182, 034, 092, 221, 158, 045, 049, 229, 144, 171, 015,
|
||||
022, 089, 025, 248, 163, 175, 081
|
||||
};
|
||||
#endregion //AlphaTestEffectShader
|
||||
|
||||
#region BasicEffectShader
|
||||
internal static byte[] BasicEffectByteCode = new byte[]
|
||||
{
|
||||
187, 004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 123, 117,
|
||||
110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116,
|
||||
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116,
|
||||
116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111,
|
||||
115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099,
|
||||
052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
|
||||
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105,
|
||||
110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118,
|
||||
101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
|
||||
111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040,
|
||||
032, 041, 123, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061,
|
||||
077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109,
|
||||
042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120,
|
||||
067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 125, 125,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034,
|
||||
123, 117, 110, 105, 102, 111, 114, 109, 032, 115, 097, 109, 112, 108, 101,
|
||||
114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 118, 097, 114,
|
||||
121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103,
|
||||
032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105,
|
||||
110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108,
|
||||
111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101,
|
||||
120, 116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105,
|
||||
113, 117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032,
|
||||
034, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, 105, 113, 117,
|
||||
101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 083, 112, 114, 105,
|
||||
116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116,
|
||||
101, 070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114,
|
||||
034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104, 093, 184, 253, 199,
|
||||
246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094,
|
||||
003, 189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172,
|
||||
146, 241, 173, 160, 182, 034, 092, 221, 158, 045, 049, 229, 144, 171, 015,
|
||||
022, 089, 025, 248, 163, 175, 081
|
||||
};
|
||||
#endregion //BasicEffectShader
|
||||
|
||||
#region DualTextureEffectShader
|
||||
internal static byte[] DualTextureEffectByteCode = new byte[]
|
||||
{
|
||||
228, 019, 118, 101, 114, 116, 101, 120, 103, 108, 111, 098, 097, 108, 123,
|
||||
117, 110, 105, 102, 111, 114, 109, 032, 118, 101, 099, 052, 032, 068, 105,
|
||||
102, 102, 117, 115, 101, 067, 111, 108, 111, 114, 059, 117, 110, 105, 102,
|
||||
111, 114, 109, 032, 118, 101, 099, 052, 032, 070, 111, 103, 086, 101, 099,
|
||||
116, 111, 114, 059, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116,
|
||||
052, 032, 087, 111, 114, 108, 100, 086, 105, 101, 119, 080, 114, 111, 106,
|
||||
059, 125, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 086, 083, 068, 117, 097, 108,
|
||||
084, 101, 120, 116, 117, 114, 101, 034, 123, 097, 116, 116, 114, 105, 098,
|
||||
117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116,
|
||||
116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 050, 032, 116, 101,
|
||||
120, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099,
|
||||
050, 032, 116, 101, 120, 050, 059, 118, 097, 114, 121, 105, 110, 103, 032,
|
||||
118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 059, 118, 097,
|
||||
114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 115, 112, 101, 099,
|
||||
117, 108, 097, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101,
|
||||
099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
|
||||
111, 114, 100, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
|
||||
050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111,
|
||||
114, 100, 050, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032,
|
||||
041, 123, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 087,
|
||||
111, 114, 108, 100, 086, 105, 101, 119, 080, 114, 111, 106, 042, 112, 111,
|
||||
115, 059, 100, 105, 102, 102, 117, 115, 101, 061, 068, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 059, 115, 112, 101, 099, 117, 108, 097,
|
||||
114, 061, 118, 101, 099, 052, 040, 048, 044, 048, 044, 048, 044, 115, 097,
|
||||
116, 117, 114, 097, 116, 101, 040, 100, 111, 116, 040, 112, 111, 115, 044,
|
||||
070, 111, 103, 086, 101, 099, 116, 111, 114, 041, 041, 041, 059, 100, 105,
|
||||
102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116,
|
||||
101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
|
||||
111, 114, 100, 050, 061, 116, 101, 120, 050, 059, 125, 125, 115, 104, 097,
|
||||
100, 101, 114, 032, 034, 086, 083, 068, 117, 097, 108, 084, 101, 120, 116,
|
||||
117, 114, 101, 078, 111, 070, 111, 103, 034, 123, 097, 116, 116, 114, 105,
|
||||
098, 117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097,
|
||||
116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 050, 032, 116,
|
||||
101, 120, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101,
|
||||
099, 050, 032, 116, 101, 120, 050, 059, 118, 097, 114, 121, 105, 110, 103,
|
||||
032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 059, 118,
|
||||
097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102,
|
||||
102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 059, 118, 097,
|
||||
114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032, 100, 105, 102, 102,
|
||||
117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 050, 059, 118, 111,
|
||||
105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123, 103, 108, 095, 080,
|
||||
111, 115, 105, 116, 105, 111, 110, 061, 087, 111, 114, 108, 100, 086, 105,
|
||||
101, 119, 080, 114, 111, 106, 042, 112, 111, 115, 059, 100, 105, 102, 102,
|
||||
117, 115, 101, 061, 068, 105, 102, 102, 117, 115, 101, 067, 111, 108, 111,
|
||||
114, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111,
|
||||
114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 084,
|
||||
101, 120, 067, 111, 111, 114, 100, 050, 061, 116, 101, 120, 050, 059, 125,
|
||||
125, 115, 104, 097, 100, 101, 114, 032, 034, 086, 083, 068, 117, 097, 108,
|
||||
084, 101, 120, 116, 117, 114, 101, 086, 101, 114, 116, 101, 120, 067, 111,
|
||||
108, 111, 114, 034, 123, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032,
|
||||
118, 101, 099, 052, 032, 112, 111, 115, 059, 097, 116, 116, 114, 105, 098,
|
||||
117, 116, 101, 032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 097, 116,
|
||||
116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 050, 032, 116, 101,
|
||||
120, 050, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101,
|
||||
099, 052, 032, 099, 111, 108, 059, 118, 097, 114, 121, 105, 110, 103, 032,
|
||||
118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 059, 118, 097,
|
||||
114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 115, 112, 101, 099,
|
||||
117, 108, 097, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101,
|
||||
099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
|
||||
111, 114, 100, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
|
||||
050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111,
|
||||
114, 100, 050, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032,
|
||||
041, 123, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 087,
|
||||
111, 114, 108, 100, 086, 105, 101, 119, 080, 114, 111, 106, 042, 112, 111,
|
||||
115, 059, 100, 105, 102, 102, 117, 115, 101, 061, 068, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 042, 099, 111, 108, 059, 115, 112, 101,
|
||||
099, 117, 108, 097, 114, 061, 118, 101, 099, 052, 040, 048, 044, 048, 044,
|
||||
048, 044, 115, 097, 116, 117, 114, 097, 116, 101, 040, 100, 111, 116, 040,
|
||||
112, 111, 115, 044, 070, 111, 103, 086, 101, 099, 116, 111, 114, 041, 041,
|
||||
041, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111,
|
||||
114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117, 115, 101, 084,
|
||||
101, 120, 067, 111, 111, 114, 100, 050, 061, 116, 101, 120, 050, 059, 125,
|
||||
125, 115, 104, 097, 100, 101, 114, 032, 034, 086, 083, 068, 117, 097, 108,
|
||||
084, 101, 120, 116, 117, 114, 101, 086, 101, 114, 116, 101, 120, 067, 111,
|
||||
108, 111, 114, 078, 111, 070, 111, 103, 034, 123, 097, 116, 116, 114, 105,
|
||||
098, 117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111, 115, 059, 097,
|
||||
116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 050, 032, 116,
|
||||
101, 120, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101,
|
||||
099, 050, 032, 116, 101, 120, 050, 059, 097, 116, 116, 114, 105, 098, 117,
|
||||
116, 101, 032, 118, 101, 099, 052, 032, 099, 111, 108, 059, 118, 097, 114,
|
||||
121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117,
|
||||
115, 101, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050,
|
||||
032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114,
|
||||
100, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
|
||||
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
|
||||
050, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123,
|
||||
103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061, 087, 111, 114,
|
||||
108, 100, 086, 105, 101, 119, 080, 114, 111, 106, 042, 112, 111, 115, 059,
|
||||
100, 105, 102, 102, 117, 115, 101, 061, 068, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 042, 099, 111, 108, 059, 100, 105, 102, 102, 117,
|
||||
115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 061, 116, 101, 120, 059,
|
||||
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
|
||||
050, 061, 116, 101, 120, 050, 059, 125, 125, 125, 102, 114, 097, 103, 109,
|
||||
101, 110, 116, 103, 108, 111, 098, 097, 108, 123, 117, 110, 105, 102, 111,
|
||||
114, 109, 032, 115, 097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101,
|
||||
120, 116, 117, 114, 101, 059, 117, 110, 105, 102, 111, 114, 109, 032, 115,
|
||||
097, 109, 112, 108, 101, 114, 050, 068, 032, 084, 101, 120, 116, 117, 114,
|
||||
101, 050, 059, 117, 110, 105, 102, 111, 114, 109, 032, 118, 101, 099, 051,
|
||||
032, 070, 111, 103, 067, 111, 108, 111, 114, 059, 125, 102, 114, 097, 103,
|
||||
109, 101, 110, 116, 115, 104, 097, 100, 101, 114, 115, 123, 115, 104, 097,
|
||||
100, 101, 114, 032, 034, 080, 083, 068, 117, 097, 108, 084, 101, 120, 116,
|
||||
117, 114, 101, 034, 123, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101,
|
||||
099, 052, 032, 100, 105, 102, 102, 117, 115, 101, 059, 118, 097, 114, 121,
|
||||
105, 110, 103, 032, 118, 101, 099, 052, 032, 115, 112, 101, 099, 117, 108,
|
||||
097, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050,
|
||||
032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114,
|
||||
100, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 050, 032,
|
||||
100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100,
|
||||
050, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032, 041, 123,
|
||||
118, 101, 099, 052, 032, 099, 111, 108, 111, 114, 061, 116, 101, 120, 116,
|
||||
117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101, 044, 100,
|
||||
105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114, 100, 041,
|
||||
059, 118, 101, 099, 052, 032, 111, 118, 101, 114, 108, 097, 121, 061, 116,
|
||||
101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114,
|
||||
101, 050, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
|
||||
111, 114, 100, 050, 041, 059, 099, 111, 108, 111, 114, 046, 114, 103, 098,
|
||||
032, 042, 061, 032, 050, 059, 099, 111, 108, 111, 114, 032, 042, 061, 032,
|
||||
111, 118, 101, 114, 108, 097, 121, 042, 100, 105, 102, 102, 117, 115, 101,
|
||||
059, 099, 111, 108, 111, 114, 046, 114, 103, 098, 061, 108, 101, 114, 112,
|
||||
040, 099, 111, 108, 111, 114, 046, 114, 103, 098, 044, 070, 111, 103, 067,
|
||||
111, 108, 111, 114, 042, 099, 111, 108, 111, 114, 046, 097, 044, 115, 112,
|
||||
101, 099, 117, 108, 097, 114, 046, 119, 041, 059, 103, 108, 095, 070, 114,
|
||||
097, 103, 067, 111, 108, 111, 114, 061, 099, 111, 108, 111, 114, 059, 125,
|
||||
125, 115, 104, 097, 100, 101, 114, 032, 034, 080, 083, 068, 117, 097, 108,
|
||||
084, 101, 120, 116, 117, 114, 101, 078, 111, 070, 111, 103, 034, 123, 118,
|
||||
097, 114, 121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102,
|
||||
102, 117, 115, 101, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101,
|
||||
099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111,
|
||||
111, 114, 100, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118, 101, 099,
|
||||
050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111,
|
||||
114, 100, 050, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 032,
|
||||
041, 123, 118, 101, 099, 052, 032, 099, 111, 108, 111, 114, 061, 116, 101,
|
||||
120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116, 117, 114, 101,
|
||||
044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067, 111, 111, 114,
|
||||
100, 041, 059, 118, 101, 099, 052, 032, 111, 118, 101, 114, 108, 097, 121,
|
||||
061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101, 120, 116,
|
||||
117, 114, 101, 050, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120,
|
||||
067, 111, 111, 114, 100, 050, 041, 059, 099, 111, 108, 111, 114, 046, 114,
|
||||
103, 098, 032, 042, 061, 032, 050, 059, 099, 111, 108, 111, 114, 032, 042,
|
||||
061, 032, 111, 118, 101, 114, 108, 097, 121, 042, 100, 105, 102, 102, 117,
|
||||
115, 101, 059, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111, 114,
|
||||
061, 099, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110,
|
||||
105, 113, 117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101,
|
||||
032, 034, 068, 117, 097, 108, 084, 101, 120, 116, 117, 114, 101, 069, 102,
|
||||
102, 101, 099, 116, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 086,
|
||||
083, 068, 117, 097, 108, 084, 101, 120, 116, 117, 114, 101, 034, 102, 114,
|
||||
097, 103, 109, 101, 110, 116, 032, 034, 080, 083, 068, 117, 097, 108, 084,
|
||||
101, 120, 116, 117, 114, 101, 034, 125, 116, 101, 099, 104, 110, 105, 113,
|
||||
117, 101, 032, 034, 068, 117, 097, 108, 084, 101, 120, 116, 117, 114, 101,
|
||||
069, 102, 102, 101, 099, 116, 078, 111, 070, 111, 103, 034, 123, 118, 101,
|
||||
114, 116, 101, 120, 032, 034, 086, 083, 068, 117, 097, 108, 084, 101, 120,
|
||||
116, 117, 114, 101, 078, 111, 070, 111, 103, 034, 102, 114, 097, 103, 109,
|
||||
101, 110, 116, 032, 034, 080, 083, 068, 117, 097, 108, 084, 101, 120, 116,
|
||||
117, 114, 101, 078, 111, 070, 111, 103, 034, 125, 116, 101, 099, 104, 110,
|
||||
105, 113, 117, 101, 032, 034, 068, 117, 097, 108, 084, 101, 120, 116, 117,
|
||||
114, 101, 069, 102, 102, 101, 099, 116, 086, 101, 114, 116, 101, 120, 067,
|
||||
111, 108, 111, 114, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 086,
|
||||
083, 068, 117, 097, 108, 084, 101, 120, 116, 117, 114, 101, 086, 101, 114,
|
||||
116, 101, 120, 067, 111, 108, 111, 114, 034, 102, 114, 097, 103, 109, 101,
|
||||
110, 116, 032, 034, 080, 083, 068, 117, 097, 108, 084, 101, 120, 116, 117,
|
||||
114, 101, 034, 125, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032, 034,
|
||||
068, 117, 097, 108, 084, 101, 120, 116, 117, 114, 101, 069, 102, 102, 101,
|
||||
099, 116, 078, 111, 070, 111, 103, 086, 101, 114, 116, 101, 120, 067, 111,
|
||||
108, 111, 114, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 086, 083,
|
||||
068, 117, 097, 108, 084, 101, 120, 116, 117, 114, 101, 086, 101, 114, 116,
|
||||
101, 120, 067, 111, 108, 111, 114, 078, 111, 070, 111, 103, 034, 102, 114,
|
||||
097, 103, 109, 101, 110, 116, 032, 034, 080, 083, 068, 117, 097, 108, 084,
|
||||
101, 120, 116, 117, 114, 101, 078, 111, 070, 111, 103, 034, 125, 125, 175,
|
||||
031, 128, 135, 091, 053, 148, 130, 202, 159, 176, 084, 033, 124, 189, 185,
|
||||
203, 176, 133, 157, 191, 216, 029, 170, 061, 255, 076, 118, 188, 098, 065,
|
||||
207, 215, 039, 153, 215, 233, 181, 035, 132, 019, 152, 136, 212, 164, 051,
|
||||
001, 074, 135, 233, 177, 169, 110, 009, 048, 124, 035, 141, 123, 034, 179,
|
||||
143, 110, 122
|
||||
};
|
||||
#endregion //DualTextureEffectShader
|
||||
|
||||
#region EnvironmentMapEffectShader
|
||||
internal static byte[] EnvironmentMapEffectByteCode = new byte[]
|
||||
{
|
||||
187, 004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 123, 117,
|
||||
110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116,
|
||||
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116,
|
||||
116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111,
|
||||
115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099,
|
||||
052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
|
||||
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105,
|
||||
110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118,
|
||||
101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
|
||||
111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040,
|
||||
032, 041, 123, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061,
|
||||
077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109,
|
||||
042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120,
|
||||
067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 125, 125,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034,
|
||||
123, 117, 110, 105, 102, 111, 114, 109, 032, 115, 097, 109, 112, 108, 101,
|
||||
114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 118, 097, 114,
|
||||
121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103,
|
||||
032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105,
|
||||
110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108,
|
||||
111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101,
|
||||
120, 116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105,
|
||||
113, 117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032,
|
||||
034, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, 105, 113, 117,
|
||||
101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 083, 112, 114, 105,
|
||||
116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116,
|
||||
101, 070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114,
|
||||
034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104, 093, 184, 253, 199,
|
||||
246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094,
|
||||
003, 189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172,
|
||||
146, 241, 173, 160, 182, 034, 092, 221, 158, 045, 049, 229, 144, 171, 015,
|
||||
022, 089, 025, 248, 163, 175, 081
|
||||
};
|
||||
#endregion //EnvironmentMapEffectShader
|
||||
|
||||
#region SkinnedEffectShader
|
||||
internal static byte[] SkinnedEffectByteCode = new byte[]
|
||||
{
|
||||
187, 004, 118, 101, 114, 116, 101, 120, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034, 123, 117,
|
||||
110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052, 032, 077, 097, 116,
|
||||
114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 097, 116,
|
||||
116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099, 052, 032, 112, 111,
|
||||
115, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101, 032, 118, 101, 099,
|
||||
052, 032, 099, 111, 108, 059, 097, 116, 116, 114, 105, 098, 117, 116, 101,
|
||||
032, 118, 101, 099, 050, 032, 116, 101, 120, 059, 118, 097, 114, 121, 105,
|
||||
110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103, 032, 118,
|
||||
101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120, 067,
|
||||
111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040,
|
||||
032, 041, 123, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111, 110, 061,
|
||||
077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109,
|
||||
042, 112, 111, 115, 059, 100, 105, 102, 102, 117, 115, 101, 084, 101, 120,
|
||||
067, 111, 111, 114, 100, 061, 116, 101, 120, 059, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 061, 099, 111, 108, 059, 125, 125, 125,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 115, 104, 097, 100, 101, 114, 115,
|
||||
123, 115, 104, 097, 100, 101, 114, 032, 034, 083, 112, 114, 105, 116, 101,
|
||||
070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114, 034,
|
||||
123, 117, 110, 105, 102, 111, 114, 109, 032, 115, 097, 109, 112, 108, 101,
|
||||
114, 050, 068, 032, 084, 101, 120, 116, 117, 114, 101, 059, 118, 097, 114,
|
||||
121, 105, 110, 103, 032, 118, 101, 099, 052, 032, 100, 105, 102, 102, 117,
|
||||
115, 101, 067, 111, 108, 111, 114, 059, 118, 097, 114, 121, 105, 110, 103,
|
||||
032, 118, 101, 099, 050, 032, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 059, 118, 111, 105, 100, 032, 109, 097, 105,
|
||||
110, 040, 032, 041, 123, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108,
|
||||
111, 114, 061, 116, 101, 120, 116, 117, 114, 101, 050, 068, 040, 084, 101,
|
||||
120, 116, 117, 114, 101, 044, 100, 105, 102, 102, 117, 115, 101, 084, 101,
|
||||
120, 067, 111, 111, 114, 100, 041, 042, 100, 105, 102, 102, 117, 115, 101,
|
||||
067, 111, 108, 111, 114, 059, 125, 125, 125, 116, 101, 099, 104, 110, 105,
|
||||
113, 117, 101, 115, 123, 116, 101, 099, 104, 110, 105, 113, 117, 101, 032,
|
||||
034, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, 105, 113, 117,
|
||||
101, 034, 123, 118, 101, 114, 116, 101, 120, 032, 034, 083, 112, 114, 105,
|
||||
116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 034,
|
||||
102, 114, 097, 103, 109, 101, 110, 116, 032, 034, 083, 112, 114, 105, 116,
|
||||
101, 070, 114, 097, 103, 109, 101, 110, 116, 083, 104, 097, 100, 101, 114,
|
||||
034, 125, 125, 085, 005, 093, 183, 066, 090, 070, 104, 093, 184, 253, 199,
|
||||
246, 081, 152, 083, 013, 048, 171, 074, 063, 021, 247, 182, 129, 011, 094,
|
||||
003, 189, 026, 178, 121, 230, 157, 193, 056, 001, 064, 136, 044, 054, 172,
|
||||
146, 241, 173, 160, 182, 034, 092, 221, 158, 045, 049, 229, 144, 171, 015,
|
||||
022, 089, 025, 248, 163, 175, 081
|
||||
};
|
||||
#endregion //SkinnedEffectShader
|
||||
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using StringPair = System.Collections.Generic.KeyValuePair<string, string>;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public class ShaderData
|
||||
{
|
||||
public string VertexGlobalCode;
|
||||
|
||||
public Dictionary<string, string> VertexShaderCodes;
|
||||
|
||||
public string FragmentGlobalCode;
|
||||
|
||||
public Dictionary<string, string> FragmentShaderCodes;
|
||||
|
||||
public Dictionary<string, StringPair> Techniques;
|
||||
|
||||
public ShaderData()
|
||||
{
|
||||
VertexShaderCodes = new Dictionary<string, string>();
|
||||
FragmentShaderCodes = new Dictionary<string, string>();
|
||||
Techniques = new Dictionary<string, StringPair>();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,362 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using StringPair = System.Collections.Generic.KeyValuePair<string, string>;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public static class ShaderHelper
|
||||
{
|
||||
#region SaveShaderCode (for external)
|
||||
public static byte[] SaveShaderCode(string effectCode)
|
||||
{
|
||||
effectCode = CleanCode(effectCode);
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
BinaryWriter writer = new BinaryWriter(stream);
|
||||
|
||||
// First of all writer the shader code (which is already preceeded
|
||||
// by a length identifier, making it harder to manipulate the code)
|
||||
writer.Write(effectCode);
|
||||
|
||||
// And now we additionally generate a sha hash so it nearly becomes
|
||||
// impossible to manipulate the shader.
|
||||
using (SHA512Managed sha = new SHA512Managed())
|
||||
{
|
||||
byte[] data = stream.ToArray();
|
||||
byte[] hash = sha.ComputeHash(data);
|
||||
// The hash is added to the end of the stream.
|
||||
writer.Write(hash);
|
||||
writer.Flush();
|
||||
}
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region LoadShaderCode
|
||||
public static string LoadShaderCode(Stream stream)
|
||||
{
|
||||
BinaryReader reader = new BinaryReader(stream);
|
||||
// First load the source.
|
||||
string source = reader.ReadString();
|
||||
byte[] hash;
|
||||
// And now check if it was manipulated.
|
||||
using (SHA512Managed sha = new SHA512Managed())
|
||||
{
|
||||
int lengthRead = (int)stream.Position;
|
||||
stream.Position = 0;
|
||||
byte[] data = reader.ReadBytes(lengthRead);
|
||||
hash = sha.ComputeHash(data);
|
||||
}
|
||||
byte[] loadedHash = reader.ReadBytes(64);
|
||||
for (int index = 0; index < hash.Length; index++)
|
||||
{
|
||||
if (hash[index] != loadedHash[index])
|
||||
{
|
||||
throw new InvalidDataException("Failed to load the shader " +
|
||||
"because the data got manipulated!");
|
||||
}
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CleanCode
|
||||
private static string CleanCode(string input)
|
||||
{
|
||||
// We wanna clean up the shader a little bit, so we remove
|
||||
// empty lines, spaces and tabs at beginning and end and also
|
||||
// remove comments.
|
||||
List<string> lines = new List<string>(input.Split('\n'));
|
||||
input = "";
|
||||
for (int index = lines.Count - 1; index >= 0; index--)
|
||||
{
|
||||
lines[index] = lines[index].Trim();
|
||||
if (String.IsNullOrEmpty(lines[index]) ||
|
||||
lines[index].StartsWith("//"))
|
||||
{
|
||||
lines.RemoveAt(index);
|
||||
continue;
|
||||
}
|
||||
|
||||
input = lines[index] + input;
|
||||
}
|
||||
|
||||
#region Multiline comment removing
|
||||
input = input.Replace("/*/*", "/* /*");
|
||||
input = input.Replace("*/*/", "*/ */");
|
||||
|
||||
int length = input.Length;
|
||||
int foundStartIndex = -1;
|
||||
int openCommentsCount = 0;
|
||||
for (int index = 0; index < length - 1; index++)
|
||||
{
|
||||
if (input[index] == '/' &&
|
||||
input[index + 1] == '*')
|
||||
{
|
||||
if (openCommentsCount == 0)
|
||||
{
|
||||
foundStartIndex = index;
|
||||
}
|
||||
openCommentsCount++;
|
||||
}
|
||||
|
||||
if (input[index] == '*' &&
|
||||
input[index + 1] == '/')
|
||||
{
|
||||
openCommentsCount--;
|
||||
if (openCommentsCount == 0)
|
||||
{
|
||||
int commentLength = index - foundStartIndex + 2;
|
||||
length -= commentLength;
|
||||
index = foundStartIndex - 1;
|
||||
input = input.Remove(foundStartIndex, commentLength);
|
||||
foundStartIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (openCommentsCount > 0)
|
||||
{
|
||||
throw new Exception("Unable to clean the shader code because it seems " +
|
||||
"some multiline comments interfere with each other or with the code. " +
|
||||
"Please make sure your shader code and comments are well formatted!");
|
||||
}
|
||||
#endregion
|
||||
|
||||
// Now to some additional cleanup
|
||||
string[] minimizables =
|
||||
{
|
||||
" * ", " = ", " + ", " / ", " - ", ", ",
|
||||
};
|
||||
|
||||
foreach (string mizable in minimizables)
|
||||
{
|
||||
input = input.Replace(mizable, mizable.Trim());
|
||||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ParseShaderCode
|
||||
public static ShaderData ParseShaderCode(string source)
|
||||
{
|
||||
ShaderData result = new ShaderData();
|
||||
|
||||
string[] partIdentifiers =
|
||||
{
|
||||
"vertexglobal",
|
||||
"vertexshaders",
|
||||
"fragmentglobal",
|
||||
"fragmentshaders",
|
||||
"techniques",
|
||||
};
|
||||
|
||||
int index = 0;
|
||||
while (index < source.Length)
|
||||
{
|
||||
for (int partIdsIndex = 0; partIdsIndex < partIdentifiers.Length; partIdsIndex++)
|
||||
{
|
||||
string partId = partIdentifiers[partIdsIndex];
|
||||
bool isValid = true;
|
||||
for (int partIndex = 0; partIndex < partId.Length; partIndex++)
|
||||
{
|
||||
if (source[index + partIndex] != partId[partIndex])
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
int startIndex = index + partId.Length;
|
||||
startIndex = source.IndexOf('{', startIndex) + 1;
|
||||
string area = ExtractArea(source, startIndex);
|
||||
index = startIndex + area.Length - 1;
|
||||
switch (partIdsIndex)
|
||||
{
|
||||
case 0:
|
||||
result.VertexGlobalCode = area;
|
||||
break;
|
||||
case 2:
|
||||
result.FragmentGlobalCode = area;
|
||||
break;
|
||||
case 1:
|
||||
ExtractNamedAreas(area, "shader", 0, result);
|
||||
break;
|
||||
case 3:
|
||||
ExtractNamedAreas(area, "shader", 1, result);
|
||||
break;
|
||||
case 4:
|
||||
ExtractNamedAreas(area, "technique", 2, result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExtractNamedAreas
|
||||
private static void ExtractNamedAreas(string areaSource, string identifier,
|
||||
int addToId, ShaderData result)
|
||||
{
|
||||
int index = 0;
|
||||
while (index < areaSource.Length)
|
||||
{
|
||||
bool isValid = true;
|
||||
for (int partIndex = 0; partIndex < identifier.Length; partIndex++)
|
||||
{
|
||||
if (areaSource[index + partIndex] != identifier[partIndex])
|
||||
{
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isValid)
|
||||
{
|
||||
int startIndex = index + identifier.Length;
|
||||
startIndex = areaSource.IndexOf('"', startIndex) + 1;
|
||||
|
||||
string name = areaSource.Substring(startIndex,
|
||||
areaSource.IndexOf('"', startIndex) - startIndex);
|
||||
|
||||
startIndex = areaSource.IndexOf('{', startIndex) + 1;
|
||||
string area = ExtractArea(areaSource, startIndex);
|
||||
|
||||
switch (addToId)
|
||||
{
|
||||
case 0:
|
||||
result.VertexShaderCodes.Add(name, area);
|
||||
break;
|
||||
case 1:
|
||||
result.FragmentShaderCodes.Add(name, area);
|
||||
break;
|
||||
case 2:
|
||||
int vertexIndex = area.IndexOf("vertex");
|
||||
vertexIndex = area.IndexOf('"', vertexIndex) + 1;
|
||||
string vertexName = area.Substring(vertexIndex,
|
||||
area.IndexOf('"', vertexIndex) - vertexIndex);
|
||||
|
||||
int fragmentIndex = area.IndexOf("fragment");
|
||||
fragmentIndex = area.IndexOf('"', fragmentIndex) + 1;
|
||||
string fragmentName = area.Substring(fragmentIndex,
|
||||
area.IndexOf('"', fragmentIndex) - fragmentIndex);
|
||||
result.Techniques.Add(name, new StringPair(vertexName, fragmentName));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExtractArea
|
||||
private static string ExtractArea(string source, int startIndex)
|
||||
{
|
||||
int endIndex = startIndex;
|
||||
int openBraceCount = 0;
|
||||
for (int index = startIndex; index < source.Length; index++)
|
||||
{
|
||||
if (source[index] == '{')
|
||||
{
|
||||
openBraceCount++;
|
||||
}
|
||||
if (source[index] == '}')
|
||||
{
|
||||
openBraceCount--;
|
||||
}
|
||||
if (openBraceCount == -1)
|
||||
{
|
||||
endIndex = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return source.Substring(startIndex, endIndex - startIndex);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private class Tests
|
||||
{
|
||||
#region TestCleanCode
|
||||
public static void TestCleanCode()
|
||||
{
|
||||
string input = File.ReadAllText(@"..\..\shader\GL3\SpriteBatch_GLSL.fx");
|
||||
Console.WriteLine(CleanCode(input));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TestCleanCodeWithExtendedComments
|
||||
public static void TestCleanCodeWithExtendedComments()
|
||||
{
|
||||
string input =
|
||||
@"// This is a simple comment.
|
||||
|
||||
/*Hello
|
||||
im a multiline comment*/
|
||||
|
||||
/* Multiline on a single line */
|
||||
|
||||
/* And now the hardcore...a multiline comment
|
||||
/*in a multiline comment/*in another one
|
||||
*/*/
|
||||
Wow...
|
||||
*/
|
||||
";
|
||||
Console.WriteLine(CleanCode(input));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TestParseShaderCode
|
||||
public static void TestParseShaderCode()
|
||||
{
|
||||
string input = CleanCode(File.ReadAllText(
|
||||
@"..\..\shader\GL3\SpriteBatch_GLSL.fx"));
|
||||
|
||||
ShaderData data = ParseShaderCode(input);
|
||||
|
||||
Console.WriteLine("Vertex globals:");
|
||||
Console.WriteLine(data.VertexGlobalCode);
|
||||
Console.WriteLine("-------------------------");
|
||||
Console.WriteLine("Fragment globals:");
|
||||
Console.WriteLine(data.FragmentGlobalCode);
|
||||
Console.WriteLine("-------------------------");
|
||||
foreach (StringPair pair in data.VertexShaderCodes)
|
||||
{
|
||||
Console.WriteLine("vertex shader: " + pair.Key);
|
||||
Console.WriteLine(pair.Value);
|
||||
Console.WriteLine("-------------------------");
|
||||
}
|
||||
foreach (StringPair pair in data.FragmentShaderCodes)
|
||||
{
|
||||
Console.WriteLine("fragment shader: " + pair.Key);
|
||||
Console.WriteLine(pair.Value);
|
||||
Console.WriteLine("-------------------------");
|
||||
}
|
||||
foreach (KeyValuePair<string, StringPair> pair in data.Techniques)
|
||||
{
|
||||
Console.WriteLine("technique: " + pair.Key);
|
||||
Console.WriteLine("vertex shader: " + pair.Value.Key);
|
||||
Console.WriteLine("fragment shader: " + pair.Value.Value);
|
||||
Console.WriteLine("-------------------------");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
using System;
|
||||
using ANX.Framework.NonXNA;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public class SupportedPlatformsImpl : ISupportedPlatforms
|
||||
{
|
||||
public PlatformName[] Names
|
||||
{
|
||||
get
|
||||
{
|
||||
return new PlatformName[]
|
||||
{
|
||||
PlatformName.WindowsXP,
|
||||
PlatformName.WindowsVista,
|
||||
PlatformName.Windows7,
|
||||
PlatformName.Windows8,
|
||||
PlatformName.Linux,
|
||||
PlatformName.MacOSX,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,339 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using ANX.RenderSystem.Windows.GL3.Helpers;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
public class Texture2DGL3 : INativeTexture2D
|
||||
{
|
||||
#region Private
|
||||
private PixelInternalFormat nativeFormat;
|
||||
|
||||
/// <summary>
|
||||
/// [1-n]
|
||||
/// </summary>
|
||||
private int numberOfMipMaps;
|
||||
|
||||
private int width;
|
||||
private int height;
|
||||
private bool isCompressed;
|
||||
internal bool IsDisposed;
|
||||
private int uncompressedDataSize;
|
||||
private byte[] texData;
|
||||
private int maxSetDataSize;
|
||||
#endregion
|
||||
|
||||
#region Public
|
||||
protected internal int NativeHandle { get; protected set; }
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
internal Texture2DGL3()
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, true);
|
||||
}
|
||||
|
||||
internal Texture2DGL3(SurfaceFormat surfaceFormat, int setWidth, int setHeight, int mipCount)
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, true);
|
||||
|
||||
width = setWidth;
|
||||
height = setHeight;
|
||||
numberOfMipMaps = mipCount;
|
||||
nativeFormat = DatatypesMapping.SurfaceToPixelInternalFormat(surfaceFormat);
|
||||
isCompressed = nativeFormat.ToString().StartsWith("Compressed");
|
||||
|
||||
uncompressedDataSize = GetUncompressedDataSize();
|
||||
|
||||
CreateTexture();
|
||||
}
|
||||
|
||||
~Texture2DGL3()
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateTexture
|
||||
private void CreateTexture()
|
||||
{
|
||||
NativeHandle = GL.GenTexture();
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
|
||||
int wrapMode = (int)All.ClampToEdge;
|
||||
All minFilter = numberOfMipMaps > 1 ? All.LinearMipmapLinear : All.Linear;
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, wrapMode);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, wrapMode);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)minFilter);
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("TexParameter");
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
// TODO: offsetInBytes
|
||||
// TODO: elementCount
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
SetData<T>(graphicsDevice, 0, data, 0, data.Length);
|
||||
}
|
||||
|
||||
public void SetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
int size = Marshal.SizeOf(typeof(T)) * data.Length;
|
||||
if (size > maxSetDataSize)
|
||||
maxSetDataSize = size;
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
|
||||
try
|
||||
{
|
||||
IntPtr dataPointer = handle.AddrOfPinnedObject();
|
||||
// Go to the starting point.
|
||||
dataPointer += startIndex;
|
||||
|
||||
int mipmapWidth = Math.Max(width >> level, 1);
|
||||
int mipmapHeight = Math.Max(height >> level, 1);
|
||||
|
||||
if (isCompressed)
|
||||
{
|
||||
GL.CompressedTexImage2D(TextureTarget.Texture2D, level, nativeFormat, width, height, 0, data.Length,
|
||||
dataPointer);
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("CompressedTexImage2D Format=" + nativeFormat);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.TexImage2D(TextureTarget.Texture2D, level, nativeFormat, mipmapWidth, mipmapHeight, 0,
|
||||
(PixelFormat)nativeFormat, PixelType.UnsignedByte, dataPointer);
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("TexImage2D Format=" + nativeFormat);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
handle.Free();
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount)
|
||||
where T : struct
|
||||
{
|
||||
int size = Marshal.SizeOf(typeof(T)) * data.Length;
|
||||
if (size > maxSetDataSize)
|
||||
maxSetDataSize = size;
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
|
||||
try
|
||||
{
|
||||
IntPtr dataPointer = handle.AddrOfPinnedObject();
|
||||
dataPointer += startIndex;
|
||||
|
||||
if (isCompressed)
|
||||
{
|
||||
GL.CompressedTexImage2D(TextureTarget.Texture2D, 0, nativeFormat, width, height, 0, data.Length, dataPointer);
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("CompressedTexImage2D Format=" + nativeFormat);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, nativeFormat, width, height, 0, (PixelFormat)nativeFormat,
|
||||
PixelType.UnsignedByte, dataPointer);
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("TexImage2D Format=" + nativeFormat);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
handle.Free();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData (TODO)
|
||||
public void GetData<T>(int level, Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
GetData(data, 0, data.Length);
|
||||
}
|
||||
#endregion
|
||||
|
||||
// TODO: compressed texture (see: http://www.bearisgaming.com/texture2d-getdata-and-dxt-compression/)
|
||||
// TODO: elementCount
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
if (isCompressed)
|
||||
throw new NotImplementedException("GetData is currently not implemented for compressed texture format " +
|
||||
nativeFormat + ".");
|
||||
|
||||
if (data == null)
|
||||
throw new ArgumentNullException("data");
|
||||
|
||||
int size = Marshal.SizeOf(typeof(T)) * data.Length;
|
||||
|
||||
if (size < uncompressedDataSize)
|
||||
throw new InvalidDataException("The size of the data passed in is too large or too small for this resource.");
|
||||
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
IntPtr ptr = handle.AddrOfPinnedObject();
|
||||
ptr += startIndex;
|
||||
|
||||
GL.GetTexImage(TextureTarget.Texture2D, 0, (PixelFormat)nativeFormat, PixelType.UnsignedByte, ptr);
|
||||
|
||||
handle.Free();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetTextureData
|
||||
private void GetTextureData()
|
||||
{
|
||||
GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
|
||||
|
||||
if (isCompressed)
|
||||
{
|
||||
texData = new byte[maxSetDataSize];
|
||||
GCHandle handle = GCHandle.Alloc(texData, GCHandleType.Pinned);
|
||||
|
||||
GL.GetCompressedTexImage(TextureTarget.Texture2D, 0, handle.AddrOfPinnedObject());
|
||||
|
||||
handle.Free();
|
||||
}
|
||||
else
|
||||
{
|
||||
texData = new byte[uncompressedDataSize];
|
||||
GCHandle handle = GCHandle.Alloc(texData, GCHandleType.Pinned);
|
||||
|
||||
GL.GetTexImage(TextureTarget.Texture2D, 0, (PixelFormat)nativeFormat, PixelType.UnsignedByte,
|
||||
handle.AddrOfPinnedObject());
|
||||
|
||||
handle.Free();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RecreateData
|
||||
internal void RecreateData()
|
||||
{
|
||||
CreateTexture();
|
||||
SetData(null, texData);
|
||||
texData = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetUncompressedDataSize
|
||||
private int GetUncompressedDataSize()
|
||||
{
|
||||
int size = width * height;
|
||||
|
||||
switch (nativeFormat)
|
||||
{
|
||||
default:
|
||||
case PixelInternalFormat.R32f:
|
||||
case PixelInternalFormat.Rgb10A2:
|
||||
case PixelInternalFormat.Rg16:
|
||||
case PixelInternalFormat.Rgba:
|
||||
size *= 4;
|
||||
break;
|
||||
|
||||
case PixelInternalFormat.Rg32f:
|
||||
case PixelInternalFormat.Rgba16f:
|
||||
size *= 8;
|
||||
break;
|
||||
|
||||
case PixelInternalFormat.R16f:
|
||||
case PixelInternalFormat.Rgb5A1:
|
||||
case PixelInternalFormat.Rgba4:
|
||||
size *= 2;
|
||||
break;
|
||||
|
||||
case PixelInternalFormat.Alpha8:
|
||||
//size *= 1;
|
||||
break;
|
||||
|
||||
case PixelInternalFormat.Rgba32f:
|
||||
size *= 16;
|
||||
break;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SaveAsJpeg (TODO)
|
||||
public void SaveAsJpeg(Stream stream, int width, int height)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SaveAsPng (TODO)
|
||||
public void SaveAsPng(Stream stream, int width, int height)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose the native OpenGL texture handle.
|
||||
/// </summary>
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if (IsDisposed == false)
|
||||
{
|
||||
IsDisposed = true;
|
||||
DisposeResource();
|
||||
}
|
||||
}
|
||||
|
||||
internal void DisposeResource()
|
||||
{
|
||||
if (IsDisposed == false)
|
||||
{
|
||||
GetTextureData();
|
||||
}
|
||||
|
||||
if (NativeHandle != -1 &&
|
||||
GraphicsDeviceWindowsGL3.IsContextCurrent)
|
||||
{
|
||||
GL.DeleteTexture(NativeHandle);
|
||||
NativeHandle = -1;
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("DeleteTexture");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,307 +0,0 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.Graphics;
|
||||
using ANX.Framework.NonXNA.RenderSystem;
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using ANX.RenderSystem.Windows.GL3.Helpers;
|
||||
|
||||
// This file is part of the ANX.Framework created by the
|
||||
// "ANX.Framework developer group" and released under the Ms-PL license.
|
||||
// For details see: http://anxframework.codeplex.com/license
|
||||
|
||||
namespace ANX.RenderSystem.Windows.GL3
|
||||
{
|
||||
/// <summary>
|
||||
/// Native OpenGL implementation of a Vertex Buffer.
|
||||
/// <para />
|
||||
/// Great tutorial about VBO/IBO directly for OpenTK:
|
||||
/// http://www.opentk.com/doc/graphics/geometry/vertex-buffer-objects
|
||||
/// </summary>
|
||||
public class VertexBufferGL3 : INativeVertexBuffer
|
||||
{
|
||||
#region Private
|
||||
private VertexBuffer managedBuffer;
|
||||
|
||||
/// <summary>
|
||||
/// Native vertex buffer handle.
|
||||
/// </summary>
|
||||
private int bufferHandle;
|
||||
internal int BufferHandle
|
||||
{
|
||||
get
|
||||
{
|
||||
return bufferHandle;
|
||||
}
|
||||
}
|
||||
|
||||
private VertexDeclaration vertexDeclaration;
|
||||
|
||||
private BufferUsage usage;
|
||||
|
||||
private int vertexCount;
|
||||
|
||||
private BufferUsageHint usageHint;
|
||||
|
||||
internal bool IsDisposed;
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
/// <summary>
|
||||
/// Create a new Vertex Buffer object.
|
||||
/// </summary>
|
||||
internal VertexBufferGL3(VertexBuffer setManagedBuffer,
|
||||
VertexDeclaration setVertexDeclaration, int setVertexCount,
|
||||
BufferUsage setUsage)
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, true);
|
||||
|
||||
managedBuffer = setManagedBuffer;
|
||||
vertexDeclaration = setVertexDeclaration;
|
||||
usage = setUsage;
|
||||
vertexCount = setVertexCount;
|
||||
|
||||
bool isDynamicBuffer = managedBuffer is DynamicVertexBuffer;
|
||||
|
||||
usageHint = isDynamicBuffer ?
|
||||
BufferUsageHint.DynamicDraw :
|
||||
BufferUsageHint.StaticDraw;
|
||||
|
||||
CreateBuffer();
|
||||
}
|
||||
|
||||
~VertexBufferGL3()
|
||||
{
|
||||
GraphicsResourceManager.UpdateResource(this, false);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateBuffer
|
||||
private void CreateBuffer()
|
||||
{
|
||||
GL.GenBuffers(1, out bufferHandle);
|
||||
ErrorHelper.Check("GenBuffers");
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
int size = vertexDeclaration.VertexStride * vertexCount;
|
||||
GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)size, IntPtr.Zero,
|
||||
usageHint);
|
||||
ErrorHelper.Check("BufferData");
|
||||
|
||||
int setSize;
|
||||
GL.GetBufferParameter(BufferTarget.ArrayBuffer,
|
||||
BufferParameterName.BufferSize, out setSize);
|
||||
if (setSize != size)
|
||||
{
|
||||
throw new Exception("Failed to set the vertexBuffer data. DataSize=" +
|
||||
size + " SetSize=" + setSize);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RecreateData
|
||||
internal void RecreateData()
|
||||
{
|
||||
CreateBuffer();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data)
|
||||
where T : struct
|
||||
{
|
||||
BufferData(data, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data,
|
||||
int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
if (startIndex != 0 ||
|
||||
elementCount != data.Length)
|
||||
{
|
||||
T[] subArray = new T[elementCount];
|
||||
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||
BufferData(subArray, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferData(data, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes,
|
||||
T[] data, int startIndex, int elementCount) where T : struct
|
||||
{
|
||||
if (startIndex != 0 ||
|
||||
elementCount != data.Length)
|
||||
{
|
||||
T[] subArray = new T[elementCount];
|
||||
Array.Copy(data, startIndex, subArray, 0, elementCount);
|
||||
BufferData(subArray, offsetInBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferData(data, offsetInBytes);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region SetData
|
||||
public void SetData<T>(GraphicsDevice graphicsDevice, int offsetInBytes,
|
||||
T[] data, int startIndex, int elementCount, int vertexStride) where T : struct
|
||||
{
|
||||
T[] elements;
|
||||
if (startIndex != 0 ||
|
||||
elementCount != data.Length)
|
||||
{
|
||||
elements = new T[elementCount];
|
||||
Array.Copy(data, startIndex, elements, 0, elementCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
elements = data;
|
||||
}
|
||||
|
||||
int size = Marshal.SizeOf(typeof(T));
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
|
||||
for (int index = 0; index < elementCount; index++)
|
||||
{
|
||||
GL.BufferSubData<T>(BufferTarget.ArrayBuffer,
|
||||
(IntPtr)offsetInBytes + (index * vertexStride),
|
||||
(IntPtr)size, ref elements[index]);
|
||||
ErrorHelper.Check("BufferSubData");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region BufferData (private helper)
|
||||
private void BufferData<T>(T[] data, int offset) where T : struct
|
||||
{
|
||||
int size = Marshal.SizeOf(typeof(T)) * data.Length;
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
|
||||
GL.BufferSubData<T>(BufferTarget.ArrayBuffer, (IntPtr)offset,
|
||||
(IntPtr)size, data);
|
||||
ErrorHelper.Check("BufferSubData");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data) where T : struct
|
||||
{
|
||||
int size = Marshal.SizeOf(typeof(T)) * data.Length;
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
|
||||
GL.GetBufferSubData<T>(BufferTarget.ArrayBuffer, IntPtr.Zero,
|
||||
(IntPtr)size, data);
|
||||
ErrorHelper.Check("GetBufferSubData");
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(T[] data, int startIndex, int elementCount)
|
||||
where T : struct
|
||||
{
|
||||
T[] copyElements = new T[elementCount];
|
||||
int size = Marshal.SizeOf(typeof(T)) * elementCount;
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
|
||||
GL.GetBufferSubData<T>(BufferTarget.ArrayBuffer, (IntPtr)0,
|
||||
(IntPtr)size, copyElements);
|
||||
ErrorHelper.Check("GetBufferSubData");
|
||||
|
||||
Array.Copy(copyElements, 0, data, startIndex, elementCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region GetData
|
||||
public void GetData<T>(int offsetInBytes, T[] data, int startIndex,
|
||||
int elementCount, int vertexStride) where T : struct
|
||||
{
|
||||
T[] copyElements = new T[elementCount];
|
||||
int size = Marshal.SizeOf(typeof(T));
|
||||
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
|
||||
for (int index = 0; index < elementCount; index++)
|
||||
{
|
||||
GL.GetBufferSubData<T>(BufferTarget.ArrayBuffer,
|
||||
(IntPtr)offsetInBytes + (index * vertexStride),
|
||||
(IntPtr)size,
|
||||
ref copyElements[index]);
|
||||
ErrorHelper.Check("GetBufferSubData");
|
||||
}
|
||||
|
||||
Array.Copy(copyElements, 0, data, startIndex, elementCount);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Bind
|
||||
public void Bind(EffectGL3 activeEffect)
|
||||
{
|
||||
GL.BindBuffer(BufferTarget.ArrayBuffer, BufferHandle);
|
||||
ErrorHelper.Check("BindBuffer");
|
||||
MapVertexDeclaration(activeEffect);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region MapVertexDeclaration
|
||||
private void MapVertexDeclaration(EffectGL3 effect)
|
||||
{
|
||||
EffectTechniqueGL3 currentTechnique = effect.CurrentTechnique;
|
||||
ShaderAttributeGL3[] attributes = currentTechnique.activeAttributes;
|
||||
VertexElement[] elements = vertexDeclaration.GetVertexElements();
|
||||
|
||||
if (elements.Length != attributes.Length)
|
||||
throw new InvalidOperationException("Mapping the VertexDeclaration onto the glsl attributes failed because " +
|
||||
"we have " + attributes.Length + " Shader Attributes and " + elements.Length + " elements in the vertex " +
|
||||
"declaration which doesn't fit!");
|
||||
|
||||
for (int index = 0; index < attributes.Length; index++)
|
||||
{
|
||||
int location = attributes[index].Location;
|
||||
attributes[index].Bind(elements[location].VertexElementUsage, vertexDeclaration.VertexStride,
|
||||
elements[location].Offset);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// Dispose the native index buffer data.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (IsDisposed == false)
|
||||
{
|
||||
IsDisposed = true;
|
||||
DisposeResource();
|
||||
}
|
||||
}
|
||||
|
||||
internal void DisposeResource()
|
||||
{
|
||||
if (bufferHandle != -1 &&
|
||||
GraphicsDeviceWindowsGL3.IsContextCurrent)
|
||||
{
|
||||
GL.DeleteBuffers(1, ref bufferHandle);
|
||||
ErrorHelper.Check("DeleteBuffers");
|
||||
bufferHandle = -1;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user