Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ported renderer to OpenTK #2408

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions Makefile
Expand Up @@ -93,7 +93,7 @@ game_SRCS := $(shell find OpenRA.Game/ -iname '*.cs')
game_TARGET = OpenRA.Game.exe
game_KIND = winexe
game_DEPS = $(fileformats_TARGET)
game_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll $(game_DEPS) thirdparty/Tao/Tao.OpenAl.dll thirdparty/SharpFont.dll
game_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll $(game_DEPS) thirdparty/OpenTK/OpenTK.dll thirdparty/OpenTK/OpenTK.Compatibility.dll thirdparty/SharpFont.dll
game_FLAGS = -win32icon:OpenRA.Game/OpenRA.ico
PROGRAMS += game
game: $(game_TARGET)
Expand All @@ -111,25 +111,25 @@ rsdl_SRCS := $(shell find OpenRA.Renderer.SdlCommon/ -iname '*.cs')
rsdl_TARGET = OpenRA.Renderer.SdlCommon.dll
rsdl_KIND = library
rsdl_DEPS = $(fileformats_TARGET) $(game_TARGET)
rsdl_LIBS = $(COMMON_LIBS) thirdparty/Tao/Tao.OpenGl.dll thirdparty/Tao/Tao.Sdl.dll $(rsdl_DEPS)
rsdl_LIBS = $(COMMON_LIBS) thirdparty/OpenTK/OpenTK.dll thirdparty/OpenTK/OpenTK.Compatibility.dll thirdparty/Tao/Tao.Sdl.dll $(rsdl_DEPS)

rcg_SRCS := $(shell find OpenRA.Renderer.Cg/ -iname '*.cs')
rcg_TARGET = OpenRA.Renderer.Cg.dll
rcg_KIND = library
rcg_DEPS = $(fileformats_TARGET) $(game_TARGET) $(rsdl_TARGET)
rcg_LIBS = $(COMMON_LIBS) thirdparty/Tao/Tao.Cg.dll thirdparty/Tao/Tao.OpenGl.dll $(rcg_DEPS)
rcg_LIBS = $(COMMON_LIBS) thirdparty/OpenTK/OpenTK.dll thirdparty/OpenTK/OpenTK.Compatibility.dll thirdparty/Tao/Tao.Cg.dll $(rcg_DEPS)

rgl_SRCS := $(shell find OpenRA.Renderer.Gl/ -iname '*.cs')
rgl_TARGET = OpenRA.Renderer.Gl.dll
rgl_KIND = library
rgl_DEPS = $(fileformats_TARGET) $(game_TARGET) $(rsdl_TARGET)
rgl_LIBS = $(COMMON_LIBS) thirdparty/Tao/Tao.OpenGl.dll $(rgl_DEPS)
rgl_LIBS = $(COMMON_LIBS) thirdparty/OpenTK/OpenTK.dll thirdparty/OpenTK/OpenTK.Compatibility.dll $(rgl_DEPS)

rsdl2_SRCS := $(shell find OpenRA.Renderer.Sdl2/ -iname '*.cs')
rsdl2_TARGET = OpenRA.Renderer.Sdl2.dll
rsdl2_KIND = library
rsdl2_DEPS = $(fileformats_TARGET) $(game_TARGET) $(rsdl_TARGET) $(rgl_TARGET)
rsdl2_LIBS = $(COMMON_LIBS) thirdparty/Tao/Tao.OpenGl.dll thirdparty/SDL2\#.dll $(rsdl2_DEPS)
rsdl2_LIBS = $(COMMON_LIBS) thirdparty/OpenTK/OpenTK.dll thirdparty/OpenTK/OpenTK.Compatibility.dll thirdparty/SDL2\#.dll $(rsdl2_DEPS)

rnull_SRCS := $(shell find OpenRA.Renderer.Null/ -iname '*.cs')
rnull_TARGET = OpenRA.Renderer.Null.dll
Expand Down Expand Up @@ -294,6 +294,7 @@ distclean: clean
dependencies:
@ $(CP_R) thirdparty/*.dl* .
@ $(CP_R) thirdparty/Tao/* .
@ $(CP_R) thirdparty/OpenTK/* .

version: mods/ra/mod.yaml mods/cnc/mod.yaml mods/d2k/mod.yaml
@for i in $? ; do \
Expand Down Expand Up @@ -331,7 +332,7 @@ install-core: default
@$(CP_R) glsl "$(DATA_INSTALL_DIR)"
@$(CP_R) cg "$(DATA_INSTALL_DIR)"
@$(CP) *.ttf "$(DATA_INSTALL_DIR)"
@$(CP) thirdparty/Tao/* "$(DATA_INSTALL_DIR)"
@$(CP) thirdparty/OpenTK/* "$(DATA_INSTALL_DIR)"
@$(CP) thirdparty/SDL2\#* "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/ICSharpCode.SharpZipLib.dll "$(DATA_INSTALL_DIR)"
@$(INSTALL_PROGRAM) thirdparty/FuzzyLogicLibrary.dll "$(DATA_INSTALL_DIR)"
Expand Down
26 changes: 13 additions & 13 deletions OpenRA.FileFormats/Graphics/IGraphicsDevice.cs
Expand Up @@ -13,44 +13,44 @@

namespace OpenRA.FileFormats.Graphics
{
[AttributeUsage( AttributeTargets.Assembly )]
[AttributeUsage(AttributeTargets.Assembly)]
public class RendererAttribute : Attribute
{
public readonly Type Type;

public RendererAttribute( Type graphicsDeviceType )
public RendererAttribute(Type graphicsDeviceType)
{
if( !typeof( IDeviceFactory ).IsAssignableFrom( graphicsDeviceType ) )
throw new InvalidOperationException( "Incorrect type in RendererAttribute" );
if (!typeof(IDeviceFactory).IsAssignableFrom(graphicsDeviceType))
throw new InvalidOperationException("Incorrect type in RendererAttribute");
Type = graphicsDeviceType;
}
}

public interface IDeviceFactory
{
IGraphicsDevice Create( Size size, WindowMode windowMode );
IGraphicsDevice Create(Size size, WindowMode windowMode);
}

public enum BlendMode { None, Alpha, Additive, Subtractive, Multiply }

public interface IGraphicsDevice
{
IVertexBuffer<Vertex> CreateVertexBuffer( int length );
ITexture CreateTexture( Bitmap bitmap );
IVertexBuffer<Vertex> CreateVertexBuffer(int length);
ITexture CreateTexture(Bitmap bitmap);
ITexture CreateTexture();
IFrameBuffer CreateFrameBuffer(Size s);
IShader CreateShader( string name );
IShader CreateShader(string name);

Size WindowSize { get; }

void Clear();
void Present();
void PumpInput(IInputHandler inputHandler);

void DrawPrimitives( PrimitiveType type, int firstVertex, int numVertices );
void DrawPrimitives(PrimitiveType type, int firstVertex, int numVertices);

void SetLineWidth( float width );
void EnableScissor( int left, int top, int width, int height );
void SetLineWidth(float width);
void EnableScissor(int left, int top, int width, int height);
void DisableScissor();

void EnableDepthBuffer();
Expand All @@ -64,7 +64,7 @@ public interface IGraphicsDevice
public interface IVertexBuffer<T>
{
void Bind();
void SetData( T[] vertices, int length );
void SetData(T[] vertices, int length);
}

public interface IShader
Expand Down Expand Up @@ -104,7 +104,7 @@ public enum PrimitiveType
public struct Range<T>
{
public readonly T Start, End;
public Range( T start, T end ) { Start = start; End = end; }
public Range(T start, T end) { Start = start; End = end; }
}

public enum WindowMode
Expand Down
8 changes: 5 additions & 3 deletions OpenRA.Game/OpenRA.Game.csproj
Expand Up @@ -75,9 +75,11 @@
<Package>mono.nat</Package>
<HintPath>..\thirdparty\Mono.Nat.dll</HintPath>
</Reference>
<Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\thirdparty\Tao\Tao.OpenAl.dll</HintPath>
<Reference Include="OpenTK">
<HintPath>..\thirdparty\OpenTK\OpenTK.dll</HintPath>
</Reference>
<Reference Include="OpenTK.Compatibility">
<HintPath>..\thirdparty\OpenTK\OpenTK.Compatibility.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down