From 3c1844bcb43cb39483b84d1b743d65152c365599 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 11 Apr 2020 21:43:00 -0400 Subject: [PATCH] Fixed references to Renderer instead of IRenderer. --- SharpDL/Graphics/Font.cs | 2 -- SharpDL/Graphics/IRenderer.cs | 28 +++++++++++++++++++++++++ SharpDL/Graphics/Image.cs | 2 +- SharpDL/Graphics/Primitive.cs | 2 +- SharpDL/Graphics/RenderTarget.cs | 4 ++-- SharpDL/Graphics/Renderer.cs | 6 +++--- SharpDL/Graphics/Texture.cs | 6 ++---- SharpDL/Graphics/TrueTypeText.cs | 2 +- SharpDL/Graphics/TrueTypeTextFactory.cs | 2 +- SharpDL/Tiles/MapContent.cs | 4 ++-- SharpDL/Tiles/Tile.cs | 3 +-- SharpDL/Tiles/TiledMap.cs | 6 +++--- 12 files changed, 45 insertions(+), 22 deletions(-) diff --git a/SharpDL/Graphics/Font.cs b/SharpDL/Graphics/Font.cs index 179602a..2572ff5 100644 --- a/SharpDL/Graphics/Font.cs +++ b/SharpDL/Graphics/Font.cs @@ -6,8 +6,6 @@ namespace SharpDL.Graphics { public class Font : IDisposable { - //private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - public string FilePath { get; private set; } public int PointSize { get; private set; } diff --git a/SharpDL/Graphics/IRenderer.cs b/SharpDL/Graphics/IRenderer.cs index 08bcde7..9e24642 100644 --- a/SharpDL/Graphics/IRenderer.cs +++ b/SharpDL/Graphics/IRenderer.cs @@ -29,6 +29,34 @@ public interface IRenderer : IDisposable /// void RenderPresent(); + /// Renders a texture identified by the texture handle at a position, angle, and center. + /// + /// Native handle to the texture being drawn. + /// X coordinate to draw the texture. + /// Y coordinate to draw the texture. + /// Source width to draw. Useful to crop. + /// Source height to draw. Useful to crop. + /// Angle of rotation of texture. + /// Center of rotation of texture. + void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight, double angle, Vector center); + + /// Renders a texture identified by the texture handle at a position, angle, and center. + /// + /// Native handle to the texture being drawn. + /// X coordinate to draw the texture. + /// Y coordinate to draw the texture. + /// Source width to draw. Useful to crop. + /// Source height to draw. Useful to crop. + void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight); + + /// Renders a texture identified by the texture handle at a position, angle, and center. + /// + /// Native handle to the texture being drawn. + /// X coordinate to draw the texture. + /// Y coordinate to draw the texture. + /// Rectangular coordinates in which to crop the texture. + void RenderTexture(IntPtr textureHandle, float positionX, float positionY, Rectangle source); + /// Resets the Renderer's render target back to null. /// void ResetRenderTarget(); diff --git a/SharpDL/Graphics/Image.cs b/SharpDL/Graphics/Image.cs index 6f5ad10..93ac885 100644 --- a/SharpDL/Graphics/Image.cs +++ b/SharpDL/Graphics/Image.cs @@ -9,7 +9,7 @@ public class Image : IDisposable public Texture Texture { get; private set; } - public Image(Renderer renderer, Surface surface, ImageFormat imageFormat) + public Image(IRenderer renderer, Surface surface, ImageFormat imageFormat) { if (renderer == null) { diff --git a/SharpDL/Graphics/Primitive.cs b/SharpDL/Graphics/Primitive.cs index 7c01681..334efb7 100644 --- a/SharpDL/Graphics/Primitive.cs +++ b/SharpDL/Graphics/Primitive.cs @@ -5,7 +5,7 @@ namespace SharpDL.Graphics { public static class Primitive { - public static void DrawLine(Renderer renderer, int x1, int y1, int x2, int y2) + public static void DrawLine(IRenderer renderer, int x1, int y1, int x2, int y2) { if (renderer == null) { diff --git a/SharpDL/Graphics/RenderTarget.cs b/SharpDL/Graphics/RenderTarget.cs index a795d5e..c3b52b3 100644 --- a/SharpDL/Graphics/RenderTarget.cs +++ b/SharpDL/Graphics/RenderTarget.cs @@ -6,7 +6,7 @@ namespace SharpDL.Graphics { public class RenderTarget : ITexture { - private Renderer renderer; + private IRenderer renderer; public uint PixelFormat { get; private set; } @@ -18,7 +18,7 @@ public class RenderTarget : ITexture public TextureAccessMode AccessMode { get; private set; } - public RenderTarget(Renderer renderer, int width, int height) + public RenderTarget(IRenderer renderer, int width, int height) { if (renderer == null) { diff --git a/SharpDL/Graphics/Renderer.cs b/SharpDL/Graphics/Renderer.cs index eabe008..b1e1e6d 100644 --- a/SharpDL/Graphics/Renderer.cs +++ b/SharpDL/Graphics/Renderer.cs @@ -63,7 +63,7 @@ public void ClearScreen() } } - internal void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight, double angle, Vector center) + public void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight, double angle, Vector center) { if (textureHandle == IntPtr.Zero) { @@ -82,13 +82,13 @@ internal void RenderTexture(IntPtr textureHandle, float positionX, float positio } } - internal void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight) + public void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight) { Rectangle source = new Rectangle(0, 0, sourceWidth, sourceHeight); RenderTexture(textureHandle, positionX, positionY, source); } - internal void RenderTexture(IntPtr textureHandle, float positionX, float positionY, Rectangle source) + public void RenderTexture(IntPtr textureHandle, float positionX, float positionY, Rectangle source) { if (textureHandle == IntPtr.Zero) { diff --git a/SharpDL/Graphics/Texture.cs b/SharpDL/Graphics/Texture.cs index 2c9eea2..cfa9776 100644 --- a/SharpDL/Graphics/Texture.cs +++ b/SharpDL/Graphics/Texture.cs @@ -6,9 +6,7 @@ namespace SharpDL.Graphics { public class Texture : ITexture { - //private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - - private Renderer renderer; + private IRenderer renderer; public string FilePath { get; private set; } @@ -26,7 +24,7 @@ public class Texture : ITexture public TextureAccessMode AccessMode { get; private set; } - public Texture(Renderer renderer, Surface surface) + public Texture(IRenderer renderer, Surface surface) { if(renderer == null) { diff --git a/SharpDL/Graphics/TrueTypeText.cs b/SharpDL/Graphics/TrueTypeText.cs index bd7dd04..8b290ff 100644 --- a/SharpDL/Graphics/TrueTypeText.cs +++ b/SharpDL/Graphics/TrueTypeText.cs @@ -19,7 +19,7 @@ public class TrueTypeText : IDisposable public int WrapLength { get; set; } - public TrueTypeText(Renderer renderer, Surface surface, string text, Font textFont, Color color, int wrapLength) + public TrueTypeText(IRenderer renderer, Surface surface, string text, Font textFont, Color color, int wrapLength) { if (renderer == null) { diff --git a/SharpDL/Graphics/TrueTypeTextFactory.cs b/SharpDL/Graphics/TrueTypeTextFactory.cs index e99283e..1ae1c5d 100644 --- a/SharpDL/Graphics/TrueTypeTextFactory.cs +++ b/SharpDL/Graphics/TrueTypeTextFactory.cs @@ -4,7 +4,7 @@ namespace SharpDL.Graphics { public static class TrueTypeTextFactory { - public static TrueTypeText CreateTrueTypeText(Renderer renderer, string fontPath, int fontSize, Color color, string text, int wrapLength) + public static TrueTypeText CreateTrueTypeText(IRenderer renderer, string fontPath, int fontSize, Color color, string text, int wrapLength) { Font font = null; Surface surface = null; diff --git a/SharpDL/Tiles/MapContent.cs b/SharpDL/Tiles/MapContent.cs index cf60d92..ceab322 100644 --- a/SharpDL/Tiles/MapContent.cs +++ b/SharpDL/Tiles/MapContent.cs @@ -42,7 +42,7 @@ public class MapContent public IReadOnlyCollection Layers { get { return layers.AsReadOnly(); } } - public MapContent(string filePath, Renderer renderer, string contentRoot) + public MapContent(string filePath, IRenderer renderer, string contentRoot) { Utilities.ThrowExceptionIfIsNullOrEmpty(filePath, "filePath"); Debug.Assert(renderer != null, "Renderer cannot be null when loading a tiled map."); @@ -135,7 +135,7 @@ private void BuildLayers(XmlDocument document) } } - private void BuildTileSetTextures(Renderer renderer, string contentRoot) + private void BuildTileSetTextures(IRenderer renderer, string contentRoot) { // build textures foreach (TileSetContent tileSet in tileSets) diff --git a/SharpDL/Tiles/Tile.cs b/SharpDL/Tiles/Tile.cs index 06a4b32..f7f895d 100644 --- a/SharpDL/Tiles/Tile.cs +++ b/SharpDL/Tiles/Tile.cs @@ -94,8 +94,7 @@ public void SetIndex(int index, int tileLayerWidth) /// this method will only render in an orthogonal projection. If isometric is required, inherit and override this method with proper behaviors. /// /// - /// - public virtual void Draw(GameTime gameTime, Renderer renderer) + public virtual void Draw(GameTime gameTime) { if (IsEmpty) return; diff --git a/SharpDL/Tiles/TiledMap.cs b/SharpDL/Tiles/TiledMap.cs index 9767dea..2911a67 100644 --- a/SharpDL/Tiles/TiledMap.cs +++ b/SharpDL/Tiles/TiledMap.cs @@ -59,7 +59,7 @@ internal class TiledMap : IDisposable /// /// Path to the .tmx file to load /// Renderer object used to load tileset textures - public TiledMap(string filePath, Renderer renderer, string contentRoot = "") + public TiledMap(string filePath, IRenderer renderer, string contentRoot = "") { MapContent mapContent = new MapContent(filePath, renderer, contentRoot); @@ -188,13 +188,13 @@ private MapObjectLayer CreateObjectLayer(LayerContent layer, Orientation orienta /// /// /// - public void Draw(GameTime gameTime, Renderer renderer) + public void Draw(GameTime gameTime, IRenderer renderer) { foreach (var tileLayer in TileLayers) { foreach (var tile in tileLayer.Tiles) { - tile.Draw(gameTime, renderer); + tile.Draw(gameTime); } } }