git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1156 993157c7-ee19-0410-b2c4-bb4e9862e678
This commit is contained in:
@@ -2,6 +2,20 @@
|
|||||||
|
|
||||||
namespace BluntDirectX { namespace Direct3D
|
namespace BluntDirectX { namespace Direct3D
|
||||||
{
|
{
|
||||||
|
generic< typename T >
|
||||||
|
public value class Range
|
||||||
|
{
|
||||||
|
T start, end;
|
||||||
|
public:
|
||||||
|
Range( T start, T end )
|
||||||
|
: start( start ), end( end )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
property T Start { T get() { return start; } }
|
||||||
|
property T End { T get() { return end; } }
|
||||||
|
};
|
||||||
|
|
||||||
public ref class GraphicsDevice
|
public ref class GraphicsDevice
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -164,5 +178,12 @@ namespace BluntDirectX { namespace Direct3D
|
|||||||
{
|
{
|
||||||
device->DrawIndexedPrimitive( (D3DPRIMITIVETYPE)primtype, 0, 0, vertexPoolSize, 0, numPrimitives );
|
device->DrawIndexedPrimitive( (D3DPRIMITIVETYPE)primtype, 0, 0, vertexPoolSize, 0, numPrimitives );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawIndexedPrimitives(PrimitiveType primType, Range<int> vertices, Range<int> indices)
|
||||||
|
{
|
||||||
|
device->DrawIndexedPrimitive( (D3DPRIMITIVETYPE)primType,
|
||||||
|
0, vertices.Start, vertices.End - vertices.Start,
|
||||||
|
indices.Start, (indices.End - indices.Start) / 3 );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ namespace OpenRa.Game
|
|||||||
void LoadVertexBuffer()
|
void LoadVertexBuffer()
|
||||||
{
|
{
|
||||||
Dictionary<Sheet, List<ushort>> indexMap = new Dictionary<Sheet, List<ushort>>();
|
Dictionary<Sheet, List<ushort>> indexMap = new Dictionary<Sheet, List<ushort>>();
|
||||||
List<Vertex> vertices = new List<Vertex>();// Vertex[] vertices = new Vertex[4 * 128 * 128];
|
List<Vertex> vertices = new List<Vertex>();
|
||||||
|
|
||||||
for (int j = 0; j < map.Height; j++)
|
for (int j = 0; j < map.Height; j++)
|
||||||
for (int i = 0; i < map.Width; i++)
|
for (int i = 0; i < map.Width; i++)
|
||||||
@@ -127,7 +127,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
ClientSize = new Size(640, 480);
|
ClientSize = new Size(1280, 800);
|
||||||
|
|
||||||
Visible = true;
|
Visible = true;
|
||||||
|
|
||||||
@@ -216,8 +216,28 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
batch.Value.Bind();
|
batch.Value.Bind();
|
||||||
|
|
||||||
device.DrawIndexedPrimitives(PrimitiveType.TriangleList,
|
int indicesPerRow = map.Width * 6;
|
||||||
vertexBuffer.Size, batch.Value.Size / 3);
|
int verticesPerRow = map.Width * 4;
|
||||||
|
|
||||||
|
int visibleRows = (int)Math.Ceiling(800.0f / 24.0f) + 2;
|
||||||
|
|
||||||
|
int firstRow = (int)((scrollPos.Y - 1) * 16.0f);
|
||||||
|
int lastRow = firstRow + visibleRows;
|
||||||
|
|
||||||
|
if (firstRow < 0)
|
||||||
|
firstRow = 0;
|
||||||
|
|
||||||
|
if (lastRow < 0)
|
||||||
|
lastRow = 0;
|
||||||
|
|
||||||
|
if (lastRow > map.Height)
|
||||||
|
lastRow = map.Height;
|
||||||
|
|
||||||
|
Range<int> indexRange = new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow);
|
||||||
|
Range<int> vertexRange = new Range<int>(verticesPerRow * firstRow, verticesPerRow * lastRow);
|
||||||
|
|
||||||
|
device.DrawIndexedPrimitives(PrimitiveType.TriangleList,
|
||||||
|
vertexRange, indexRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
effect.EndPass();
|
effect.EndPass();
|
||||||
|
|||||||
Reference in New Issue
Block a user