Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added missing TextureCollection for GraphicsDevice and removed tempor…

…ary #ifdefs for iOS

git-svn-id: https://xnatouch.svn.codeplex.com/svn@59382 ffd33b8c-2492-42e0-bdc5-587b920b7d6d
  • Loading branch information...
commit 589b2665790e4265a6fd9b2b9260a671fe201f4f 1 parent eaab573
SND\kelthar_cp authored
View
1  MonoGame.Framework/Graphics/GraphicsDevice.cs
@@ -55,6 +55,7 @@ public class GraphicsDevice : IDisposable
private bool _isDisposed = false;
private readonly DisplayMode _displayMode = new DisplayMode();
private RenderState _renderState;
+ public TextureCollection Textures { get; set; }
internal List<IntPtr> _pointerCache = new List<IntPtr>();
private VertexBuffer _vertexBuffer = null;
private IndexBuffer _indexBuffer = null;
View
18 MonoGame.Framework/Graphics/TextureCollection.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Microsoft.Xna.Framework.Graphics
+{
+ public class TextureCollection
+ {
+ Dictionary<int, Texture> _textures = new Dictionary<int, Texture>();
+
+ public Texture this[int index]
+ {
+ get { return _textures[index]; }
+ set { _textures[index] = value; }
+ }
+ }
+}
View
1  MonoGame.Framework/MonoGame.Framework.Windows.csproj
@@ -74,6 +74,7 @@
<Compile Include="Graphics\States\SamplerState.cs" />
<Compile Include="Graphics\States\SaveStateMode.cs" />
<Compile Include="Graphics\States\StencilOperation.cs" />
+ <Compile Include="Graphics\TextureCollection.cs" />
<Compile Include="Graphics\Vertices\BufferUsage.cs" />
<Compile Include="Graphics\Vertices\IndexBuffer.cs" />
<Compile Include="Graphics\Vertices\IVertexType.cs" />
View
55 MonoGame.Framework/Windows/Graphics/GraphicsDevice.cs
@@ -62,6 +62,7 @@ public class GraphicsDevice : IDisposable
internal List<IntPtr> _pointerCache = new List<IntPtr>();
private VertexBuffer _vertexBuffer = null;
private IndexBuffer _indexBuffer = null;
+ public TextureCollection Textures { get; set; }
public static RasterizerState RasterizerState { get; set; }
public static DepthStencilState DepthStencilState { get; set; }
@@ -355,25 +356,6 @@ RenderTarget2D renderTarget
throw new NotImplementedException();
}
-#if IPHONE
- public All PrimitiveTypeGL11(PrimitiveType primitiveType)
- {
- switch (primitiveType)
- {
- case PrimitiveType.LineList:
- return All.Lines;
- case PrimitiveType.LineStrip:
- return All.LineStrip;
- case PrimitiveType.TriangleList:
- return All.Triangles;
- case PrimitiveType.TriangleStrip:
- return All.TriangleStrip;
- }
-
- throw new NotImplementedException();
- }
-#endif
-#if WINDOWS
public BeginMode PrimitiveTypeGL11(PrimitiveType primitiveType)
{
switch (primitiveType)
@@ -390,28 +372,17 @@ public BeginMode PrimitiveTypeGL11(PrimitiveType primitiveType)
throw new NotImplementedException();
}
-#endif
public void SetVertexBuffer(VertexBuffer vertexBuffer)
{
_vertexBuffer = vertexBuffer;
-#if IPHONE
- GL.BindBuffer(All.ArrayBuffer, vertexBuffer._bufferStore);
-#endif
-#if WINDOWS
GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer._bufferStore);
-#endif
}
private void SetIndexBuffer(IndexBuffer indexBuffer)
{
_indexBuffer = indexBuffer;
-#if IPHONE
- GL.BindBuffer(All.ElementArrayBuffer, indexBuffer._bufferStore);
-#endif
-#if WINDOWS
GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBuffer._bufferStore);
-#endif
}
public IndexBuffer Indices { set { SetIndexBuffer(value); } }
@@ -425,25 +396,15 @@ public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, i
// Hmm, can the pointer here be changed with baseVertex?
VertexDeclaration.PrepareForUse(vd, IntPtr.Zero);
-#if IPHONE
- GL.DrawElements(PrimitiveTypeGL11(primitiveType), _indexBuffer._count, All.UnsignedShort, new IntPtr(startIndex));
-#endif
-#if WINDOWS
GL.DrawElements(PrimitiveTypeGL11(primitiveType), _indexBuffer._count, DrawElementsType.UnsignedShort, startIndex);
-#endif
}
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount) where T : struct, IVertexType
{
// Unbind the VBOs
-#if IPHONE
- GL.BindBuffer(All.ArrayBuffer, 0);
- GL.BindBuffer(All.ElementArrayBuffer, 0);
-#endif
-#if WINDOWS
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
-#endif
+
var vd = VertexDeclaration.FromType(typeof(T));
IntPtr arrayStart = GCHandle.Alloc(vertexData, GCHandleType.Pinned).AddrOfPinnedObject();
@@ -472,14 +433,9 @@ public void DrawPrimitives(PrimitiveType primitiveType, int vertexStart, int pri
throw new NotImplementedException("vertexOffset and indexOffset is not yet supported.");
// Unload the VBOs
-#if IPHONE
- GL.BindBuffer(All.VertexArray, 0);
- GL.BindBuffer(All.ElementArrayBuffer, 0);
-#endif
-#if WINDOWS
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);
-#endif
+
var vd = VertexDeclaration.FromType(typeof(T));
IntPtr arrayStart = GCHandle.Alloc(vertexData, GCHandleType.Pinned).AddrOfPinnedObject();
@@ -487,12 +443,7 @@ public void DrawPrimitives(PrimitiveType primitiveType, int vertexStart, int pri
arrayStart = new IntPtr(arrayStart.ToInt32() + vertexOffset);
VertexDeclaration.PrepareForUse(vd, arrayStart);
-#if IPHONE
- GL.DrawElements(PrimitiveTypeGL11(primitiveType), vertexCount, All.UnsignedShort, indexData);
-#endif
-#if WINDOWS
GL.DrawElements(PrimitiveTypeGL11(primitiveType), vertexCount, DrawElementsType.UnsignedShort, indexData);
-#endif
}
public int getElementCountArray(PrimitiveType primitiveType, int primitiveCount)
Please sign in to comment.
Something went wrong with that request. Please try again.