Expose Graphics.Renderer setting; Refactor Renderer.Null.
This commit is contained in:
12
Makefile
12
Makefile
@@ -1,7 +1,7 @@
|
|||||||
CSC = gmcs
|
CSC = gmcs
|
||||||
CSFLAGS = -nologo -warn:4 -debug:+ -debug:full -optimize- -codepage:utf8 -unsafe
|
CSFLAGS = -nologo -warn:4 -debug:+ -debug:full -optimize- -codepage:utf8 -unsafe
|
||||||
DEFINE = DEBUG;TRACE
|
DEFINE = DEBUG;TRACE
|
||||||
PROGRAMS = fileformats rcg rgl game ra cnc seqed editor ralint filex tsbuild utility
|
PROGRAMS = fileformats rcg rgl rnull game ra cnc seqed editor ralint filex tsbuild utility
|
||||||
prefix = /usr/local
|
prefix = /usr/local
|
||||||
datarootdir = $(prefix)/share
|
datarootdir = $(prefix)/share
|
||||||
datadir = $(datarootdir)
|
datadir = $(datarootdir)
|
||||||
@@ -25,6 +25,7 @@ rcg_DEPS = $(fileformats_TARGET) $(game_TARGET)
|
|||||||
rcg_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll \
|
rcg_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll \
|
||||||
thirdparty/Tao/Tao.Cg.dll thirdparty/Tao/Tao.OpenGl.dll thirdparty/Tao/Tao.Sdl.dll \
|
thirdparty/Tao/Tao.Cg.dll thirdparty/Tao/Tao.OpenGl.dll thirdparty/Tao/Tao.Sdl.dll \
|
||||||
$(rcg_DEPS) $(game_TARGET)
|
$(rcg_DEPS) $(game_TARGET)
|
||||||
|
|
||||||
rgl_SRCS = $(shell find OpenRA.Renderer.Gl/ -iname '*.cs')
|
rgl_SRCS = $(shell find OpenRA.Renderer.Gl/ -iname '*.cs')
|
||||||
rgl_TARGET = OpenRA.Renderer.Gl.dll
|
rgl_TARGET = OpenRA.Renderer.Gl.dll
|
||||||
rgl_KIND = library
|
rgl_KIND = library
|
||||||
@@ -33,6 +34,13 @@ rgl_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll \
|
|||||||
thirdparty/Tao/Tao.Cg.dll thirdparty/Tao/Tao.OpenGl.dll thirdparty/Tao/Tao.Sdl.dll \
|
thirdparty/Tao/Tao.Cg.dll thirdparty/Tao/Tao.OpenGl.dll thirdparty/Tao/Tao.Sdl.dll \
|
||||||
$(rgl_DEPS) $(game_TARGET)
|
$(rgl_DEPS) $(game_TARGET)
|
||||||
|
|
||||||
|
rnull_SRCS = $(shell find OpenRA.Renderer.Null/ -iname '*.cs')
|
||||||
|
rnull_TARGET = OpenRA.Renderer.Null.dll
|
||||||
|
rnull_KIND = library
|
||||||
|
rnull_DEPS = $(fileformats_TARGET) $(game_TARGET)
|
||||||
|
rnull_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll \
|
||||||
|
$(rnull_DEPS) $(game_TARGET)
|
||||||
|
|
||||||
game_SRCS = $(shell find OpenRA.Game/ -iname '*.cs')
|
game_SRCS = $(shell find OpenRA.Game/ -iname '*.cs')
|
||||||
game_TARGET = OpenRA.Game.exe
|
game_TARGET = OpenRA.Game.exe
|
||||||
game_KIND = winexe
|
game_KIND = winexe
|
||||||
@@ -98,7 +106,7 @@ utility_LIBS = $(COMMON_LIBS) $(utility_DEPS)
|
|||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.PHONY: clean all game tool default mods mod_ra mod_cnc install uninstall editor_res editor tsbuild ralint seqed filex utility
|
.PHONY: clean all game tool default mods mod_ra mod_cnc install uninstall editor_res editor tsbuild ralint seqed filex utility
|
||||||
|
|
||||||
game: $(fileformats_TARGET) $(rcg_TARGET) $(rgl_TARGET) $(game_TARGET) $(ra_TARGET) $(cnc_TARGET) $(utility_TARGET)
|
game: $(fileformats_TARGET) $(rcg_TARGET) $(rgl_TARGET) $(rnull_TARGET) $(game_TARGET) $(ra_TARGET) $(cnc_TARGET) $(utility_TARGET)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@-rm *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb *.resources
|
@-rm *.exe *.dll *.mdb mods/**/*.dll mods/**/*.mdb *.resources
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace OpenRA.GameRules
|
|||||||
|
|
||||||
public class GraphicSettings
|
public class GraphicSettings
|
||||||
{
|
{
|
||||||
|
public string Renderer = "Cg";
|
||||||
public WindowMode Mode = WindowMode.PseudoFullscreen;
|
public WindowMode Mode = WindowMode.PseudoFullscreen;
|
||||||
public int2 FullscreenSize = new int2(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
|
public int2 FullscreenSize = new int2(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
|
||||||
public int2 WindowedSize = new int2(1024, 768);
|
public int2 WindowedSize = new int2(1024, 768);
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ namespace OpenRA.Graphics
|
|||||||
internal static void Initialize( OpenRA.FileFormats.Graphics.WindowMode windowMode )
|
internal static void Initialize( OpenRA.FileFormats.Graphics.WindowMode windowMode )
|
||||||
{
|
{
|
||||||
var resolution = GetResolution( windowMode );
|
var resolution = GetResolution( windowMode );
|
||||||
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRA.Renderer.Gl.dll" ) ), resolution.Width, resolution.Height, windowMode, false );
|
device = CreateDevice( Assembly.LoadFile( Path.GetFullPath( "OpenRA.Renderer.{0}.dll".F(Game.Settings.Graphics.Renderer) ) ), resolution.Width, resolution.Height, windowMode, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
static Size GetResolution(WindowMode windowmode)
|
static Size GetResolution(WindowMode windowmode)
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ namespace OpenRA.Renderer.Cg
|
|||||||
|
|
||||||
public GraphicsDevice( int width, int height, WindowMode window, bool vsync )
|
public GraphicsDevice( int width, int height, WindowMode window, bool vsync )
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Using Cg renderer");
|
||||||
Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO );
|
Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO );
|
||||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 );
|
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 );
|
||||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 );
|
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 );
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ namespace OpenRA.Renderer.Glsl
|
|||||||
|
|
||||||
public GraphicsDevice( int width, int height, WindowMode window, bool vsync )
|
public GraphicsDevice( int width, int height, WindowMode window, bool vsync )
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Using Gl renderer");
|
||||||
Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO );
|
Sdl.SDL_Init( Sdl.SDL_INIT_NOPARACHUTE | Sdl.SDL_INIT_VIDEO );
|
||||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 );
|
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_DOUBLEBUFFER, 1 );
|
||||||
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 );
|
Sdl.SDL_GL_SetAttribute( Sdl.SDL_GL_RED_SIZE, 8 );
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System.Drawing;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using OpenRA.FileFormats.Graphics;
|
using OpenRA.FileFormats.Graphics;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using System;
|
||||||
|
|
||||||
[assembly: Renderer(typeof(OpenRA.Renderer.Null.NullGraphicsDevice))]
|
[assembly: Renderer(typeof(OpenRA.Renderer.Null.NullGraphicsDevice))]
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ namespace OpenRA.Renderer.Null
|
|||||||
|
|
||||||
public NullGraphicsDevice(int width, int height, WindowMode window, bool vsync)
|
public NullGraphicsDevice(int width, int height, WindowMode window, bool vsync)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Using Null renderer");
|
||||||
WindowSize = new Size(width, height);
|
WindowSize = new Size(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,4 +48,31 @@ namespace OpenRA.Renderer.Null
|
|||||||
public ITexture CreateTexture(Bitmap bitmap) { return new NullTexture(); }
|
public ITexture CreateTexture(Bitmap bitmap) { return new NullTexture(); }
|
||||||
public IShader CreateShader(string name) { return new NullShader(); }
|
public IShader CreateShader(string name) { return new NullShader(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class NullIndexBuffer : IIndexBuffer
|
||||||
|
{
|
||||||
|
public void Bind() {}
|
||||||
|
public void SetData(ushort[] indices, int length) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NullShader : IShader
|
||||||
|
{
|
||||||
|
public void SetValue(string name, float x, float y) { }
|
||||||
|
public void SetValue(string param, ITexture texture) { }
|
||||||
|
public void Commit() { }
|
||||||
|
public void Render(Action a) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class NullTexture : ITexture
|
||||||
|
{
|
||||||
|
public void SetData(Bitmap bitmap) { }
|
||||||
|
public void SetData(uint[,] colors) { }
|
||||||
|
public void SetData(byte[] colors, int width, int height) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
class NullVertexBuffer<T> : IVertexBuffer<T>
|
||||||
|
{
|
||||||
|
public void Bind() { }
|
||||||
|
public void SetData(T[] vertices, int length) { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2010 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 LICENSE.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using OpenRA.FileFormats.Graphics;
|
|
||||||
|
|
||||||
namespace OpenRA.Renderer.Null
|
|
||||||
{
|
|
||||||
public class NullIndexBuffer : IIndexBuffer
|
|
||||||
{
|
|
||||||
public void Bind() {}
|
|
||||||
public void SetData(ushort[] indices, int length) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2010 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 LICENSE.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using OpenRA.FileFormats.Graphics;
|
|
||||||
|
|
||||||
namespace OpenRA.Renderer.Null
|
|
||||||
{
|
|
||||||
public class NullShader : IShader
|
|
||||||
{
|
|
||||||
public void SetValue(string name, float x, float y) { }
|
|
||||||
public void SetValue(string param, ITexture texture) { }
|
|
||||||
public void Commit() { }
|
|
||||||
public void Render(Action a) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2010 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 LICENSE.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System.Drawing;
|
|
||||||
using OpenRA.FileFormats.Graphics;
|
|
||||||
|
|
||||||
namespace OpenRA.Renderer.Null
|
|
||||||
{
|
|
||||||
public class NullTexture : ITexture
|
|
||||||
{
|
|
||||||
public void SetData(Bitmap bitmap) { }
|
|
||||||
public void SetData(uint[,] colors) { }
|
|
||||||
public void SetData(byte[] colors, int width, int height) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2010 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 LICENSE.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using OpenRA.FileFormats.Graphics;
|
|
||||||
|
|
||||||
namespace OpenRA.Renderer.Null
|
|
||||||
{
|
|
||||||
class NullVertexBuffer<T> : IVertexBuffer<T>
|
|
||||||
{
|
|
||||||
public void Bind() { }
|
|
||||||
public void SetData(T[] vertices, int length) { }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -48,10 +48,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="NullGraphicsDevice.cs" />
|
<Compile Include="NullGraphicsDevice.cs" />
|
||||||
<Compile Include="NullIndexBuffer.cs" />
|
|
||||||
<Compile Include="NullShader.cs" />
|
|
||||||
<Compile Include="NullTexture.cs" />
|
|
||||||
<Compile Include="NullVertexBuffer.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user