Skip to content

Commit

Permalink
Fixed references to Renderer instead of IRenderer.
Browse files Browse the repository at this point in the history
  • Loading branch information
babelshift committed Apr 12, 2020
1 parent 7615685 commit 3c1844b
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 22 deletions.
2 changes: 0 additions & 2 deletions SharpDL/Graphics/Font.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
28 changes: 28 additions & 0 deletions SharpDL/Graphics/IRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ public interface IRenderer : IDisposable
/// </summary>
void RenderPresent();

/// <summary>Renders a texture identified by the texture handle at a position, angle, and center.
/// </summary>
/// <param name="textureHandle">Native handle to the texture being drawn.</param>
/// <param name="positionX">X coordinate to draw the texture.</param>
/// <param name="positionY">Y coordinate to draw the texture.</param>
/// <param name="sourceWidth">Source width to draw. Useful to crop.</param>
/// <param name="sourceHeight">Source height to draw. Useful to crop.</param>
/// <param name="angle">Angle of rotation of texture.</param>
/// <param name="center">Center of rotation of texture.</param>
void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight, double angle, Vector center);

/// <summary>Renders a texture identified by the texture handle at a position, angle, and center.
/// </summary>
/// <param name="textureHandle">Native handle to the texture being drawn.</param>
/// <param name="positionX">X coordinate to draw the texture.</param>
/// <param name="positionY">Y coordinate to draw the texture.</param>
/// <param name="sourceWidth">Source width to draw. Useful to crop.</param>
/// <param name="sourceHeight">Source height to draw. Useful to crop.</param>
void RenderTexture(IntPtr textureHandle, float positionX, float positionY, int sourceWidth, int sourceHeight);

/// <summary>Renders a texture identified by the texture handle at a position, angle, and center.
/// </summary>
/// <param name="textureHandle">Native handle to the texture being drawn.</param>
/// <param name="positionX">X coordinate to draw the texture.</param>
/// <param name="positionY">Y coordinate to draw the texture.</param>
/// <param name="source">Rectangular coordinates in which to crop the texture.</param>
void RenderTexture(IntPtr textureHandle, float positionX, float positionY, Rectangle source);

/// <summary>Resets the Renderer's render target back to null.
/// </summary>
void ResetRenderTarget();
Expand Down
2 changes: 1 addition & 1 deletion SharpDL/Graphics/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion SharpDL/Graphics/Primitive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions SharpDL/Graphics/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace SharpDL.Graphics
{
public class RenderTarget : ITexture
{
private Renderer renderer;
private IRenderer renderer;

public uint PixelFormat { get; private set; }

Expand All @@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions SharpDL/Graphics/Renderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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)
{
Expand Down
6 changes: 2 additions & 4 deletions SharpDL/Graphics/Texture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion SharpDL/Graphics/TrueTypeText.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion SharpDL/Graphics/TrueTypeTextFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions SharpDL/Tiles/MapContent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class MapContent

public IReadOnlyCollection<LayerContent> 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.");
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions SharpDL/Tiles/Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// </summary>
/// <param name="gameTime"></param>
/// <param name="renderer"></param>
public virtual void Draw(GameTime gameTime, Renderer renderer)
public virtual void Draw(GameTime gameTime)
{
if (IsEmpty) return;

Expand Down
6 changes: 3 additions & 3 deletions SharpDL/Tiles/TiledMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ internal class TiledMap : IDisposable
/// </summary>
/// <param name="filePath">Path to the .tmx file to load</param>
/// <param name="renderer">Renderer object used to load tileset textures</param>
public TiledMap(string filePath, Renderer renderer, string contentRoot = "")
public TiledMap(string filePath, IRenderer renderer, string contentRoot = "")
{
MapContent mapContent = new MapContent(filePath, renderer, contentRoot);

Expand Down Expand Up @@ -188,13 +188,13 @@ private MapObjectLayer CreateObjectLayer(LayerContent layer, Orientation orienta
/// </summary>
/// <param name="gameTime"></param>
/// <param name="renderer"></param>
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);
}
}
}
Expand Down

0 comments on commit 3c1844b

Please sign in to comment.