untie the engine from SDL2 and MiniTK
This commit is contained in:
101
OpenRA.Platforms.Null/NullGraphicsDevice.cs
Normal file
101
OpenRA.Platforms.Null/NullGraphicsDevice.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA.Graphics;
|
||||
|
||||
namespace OpenRA.Platforms.Null
|
||||
{
|
||||
public sealed class NullGraphicsDevice : IGraphicsDevice
|
||||
{
|
||||
public Size WindowSize { get; internal set; }
|
||||
|
||||
public NullGraphicsDevice(Size size, WindowMode window)
|
||||
{
|
||||
Console.WriteLine("Using Null renderer");
|
||||
WindowSize = size;
|
||||
}
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
public void EnableScissor(int left, int top, int width, int height) { }
|
||||
public void DisableScissor() { }
|
||||
|
||||
public void EnableDepthBuffer() { }
|
||||
public void DisableDepthBuffer() { }
|
||||
|
||||
public void SetBlendMode(BlendMode mode) { }
|
||||
|
||||
public void GrabWindowMouseFocus() { }
|
||||
public void ReleaseWindowMouseFocus() { }
|
||||
|
||||
public void Clear() { }
|
||||
public void Present() { }
|
||||
public Bitmap TakeScreenshot() { return new Bitmap(1, 1); }
|
||||
|
||||
public string GetClipboardText() { return ""; }
|
||||
public void PumpInput(IInputHandler ih)
|
||||
{
|
||||
Game.HasInputFocus = false;
|
||||
ih.ModifierKeys(Modifiers.None);
|
||||
}
|
||||
|
||||
public void DrawPrimitives(PrimitiveType pt, int firstVertex, int numVertices) { }
|
||||
public void SetLineWidth(float width) { }
|
||||
|
||||
public IVertexBuffer<Vertex> CreateVertexBuffer(int size) { return new NullVertexBuffer<Vertex>(); }
|
||||
public ITexture CreateTexture() { return new NullTexture(); }
|
||||
public ITexture CreateTexture(Bitmap bitmap) { return new NullTexture(); }
|
||||
public IFrameBuffer CreateFrameBuffer(Size s) { return new NullFrameBuffer(); }
|
||||
public IShader CreateShader(string name) { return new NullShader(); }
|
||||
|
||||
public IHardwareCursor CreateHardwareCursor(string name, Size size, byte[] data, int2 hotspot) { return null; }
|
||||
public void SetHardwareCursor(IHardwareCursor cursor) { }
|
||||
}
|
||||
|
||||
public class NullShader : IShader
|
||||
{
|
||||
public void SetVec(string name, float x) { }
|
||||
public void SetVec(string name, float x, float y) { }
|
||||
public void SetVec(string name, float[] vec, int length) { }
|
||||
public void SetTexture(string param, ITexture texture) { }
|
||||
public void SetMatrix(string param, float[] mtx) { }
|
||||
public void Render(Action a) { }
|
||||
}
|
||||
|
||||
public sealed class NullTexture : ITexture
|
||||
{
|
||||
public TextureScaleFilter ScaleFilter { get { return TextureScaleFilter.Nearest; } set { } }
|
||||
public void SetData(Bitmap bitmap) { }
|
||||
public void SetData(uint[,] colors) { }
|
||||
public void SetData(byte[] colors, int width, int height) { }
|
||||
public byte[] GetData() { return new byte[0]; }
|
||||
public Size Size { get { return new Size(0, 0); } }
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
public sealed class NullFrameBuffer : IFrameBuffer
|
||||
{
|
||||
public void Bind() { }
|
||||
public void Unbind() { }
|
||||
public ITexture Texture { get { return new NullTexture(); } }
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
sealed class NullVertexBuffer<T> : IVertexBuffer<T>
|
||||
{
|
||||
public void Bind() { }
|
||||
public void SetData(T[] vertices, int length) { }
|
||||
public void SetData(T[] vertices, int start, int length) { }
|
||||
public void SetData(IntPtr data, int start, int length) { }
|
||||
public void Dispose() { }
|
||||
}
|
||||
}
|
||||
31
OpenRA.Platforms.Null/NullPlatform.cs
Normal file
31
OpenRA.Platforms.Null/NullPlatform.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using OpenRA;
|
||||
|
||||
[assembly: Platform(typeof(OpenRA.Platforms.Null.DeviceFactory))]
|
||||
|
||||
namespace OpenRA.Platforms.Null
|
||||
{
|
||||
public class DeviceFactory : IDeviceFactory
|
||||
{
|
||||
public IGraphicsDevice CreateGraphics(Size size, WindowMode windowMode)
|
||||
{
|
||||
return new NullGraphicsDevice(size, windowMode);
|
||||
}
|
||||
|
||||
public ISoundEngine CreateSound()
|
||||
{
|
||||
return new NullSoundEngine();
|
||||
}
|
||||
}
|
||||
}
|
||||
55
OpenRA.Platforms.Null/NullSound.cs
Normal file
55
OpenRA.Platforms.Null/NullSound.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenRA.Platforms.Null
|
||||
{
|
||||
class NullSoundEngine : ISoundEngine
|
||||
{
|
||||
public SoundDevice[] AvailableDevices()
|
||||
{
|
||||
return new[] { new SoundDevice("Null", null, "Output Disabled") };
|
||||
}
|
||||
|
||||
public NullSoundEngine()
|
||||
{
|
||||
Console.WriteLine("Using Null sound engine which disables SFX completely");
|
||||
}
|
||||
|
||||
public ISoundSource AddSoundSourceFromMemory(byte[] data, int channels, int sampleBits, int sampleRate)
|
||||
{
|
||||
return new NullSoundSource();
|
||||
}
|
||||
|
||||
public ISound Play2D(ISoundSource sound, bool loop, bool relative, WPos pos, float volume, bool attenuateVolume)
|
||||
{
|
||||
return new NullSound();
|
||||
}
|
||||
|
||||
public void PauseSound(ISound sound, bool paused) { }
|
||||
public void StopSound(ISound sound) { }
|
||||
public void SetAllSoundsPaused(bool paused) { }
|
||||
public void StopAllSounds() { }
|
||||
public void SetListenerPosition(WPos position) { }
|
||||
public void SetSoundVolume(float volume, ISound music, ISound video) { }
|
||||
|
||||
public float Volume { get; set; }
|
||||
}
|
||||
|
||||
class NullSoundSource : ISoundSource { }
|
||||
|
||||
class NullSound : ISound
|
||||
{
|
||||
public float Volume { get; set; }
|
||||
public float SeekPosition { get { return 0; } }
|
||||
public bool Playing { get { return false; } }
|
||||
}
|
||||
}
|
||||
98
OpenRA.Platforms.Null/OpenRA.Platforms.Null.csproj
Normal file
98
OpenRA.Platforms.Null/OpenRA.Platforms.Null.csproj
Normal file
@@ -0,0 +1,98 @@
|
||||
<?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>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0C4AEC1A-E7D5-4114-8CCD-3EEC82872981}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OpenRA.Platforms.Null</RootNamespace>
|
||||
<AssemblyName>OpenRA.Platforms.Null</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags></FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<PublishUrl>publish\</PublishUrl>
|
||||
<Install>true</Install>
|
||||
<InstallFrom>Disk</InstallFrom>
|
||||
<UpdateEnabled>false</UpdateEnabled>
|
||||
<UpdateMode>Foreground</UpdateMode>
|
||||
<UpdateInterval>7</UpdateInterval>
|
||||
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||
<UpdatePeriodically>false</UpdatePeriodically>
|
||||
<UpdateRequired>false</UpdateRequired>
|
||||
<MapFileExtensions>true</MapFileExtensions>
|
||||
<ApplicationRevision>0</ApplicationRevision>
|
||||
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Optimize>true</Optimize>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="Eluant">
|
||||
<HintPath>..\thirdparty\download\Eluant.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="NullGraphicsDevice.cs" />
|
||||
<Compile Include="NullSound.cs" />
|
||||
<Compile Include="NullPlatform.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||
<Name>OpenRA.Game</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
|
||||
<Install>false</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
|
||||
<Visible>False</Visible>
|
||||
<ProductName>Windows Installer 3.1</ProductName>
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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>
|
||||
Reference in New Issue
Block a user