added null renderer, game runs. good place to start.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Ijw.DirectX;
|
||||
using OpenRa.Gl;
|
||||
using OpenRa.FileFormats;
|
||||
using OpenRa.Support;
|
||||
|
||||
@@ -19,14 +19,13 @@ namespace OpenRa.Graphics
|
||||
|
||||
public Texture PaletteTexture;
|
||||
|
||||
readonly SpriteHelper sh;
|
||||
readonly FontHelper fhDebug, fhTitle;
|
||||
//readonly SpriteHelper sh;
|
||||
//readonly FontHelper fhDebug, fhTitle;
|
||||
|
||||
public Renderer(Control host, Size resolution, bool windowed)
|
||||
{
|
||||
host.ClientSize = resolution;
|
||||
device = GraphicsDevice.Create(host,
|
||||
resolution.Width, resolution.Height, windowed, false);
|
||||
device = new GraphicsDevice(host, resolution.Width, resolution.Height, windowed, false);
|
||||
|
||||
SpriteShader = new Shader(device, FileSystem.Open("world-shp.fx"));
|
||||
SpriteShader.Quality = ShaderQuality.Low;
|
||||
@@ -37,9 +36,9 @@ namespace OpenRa.Graphics
|
||||
WorldSpriteShader = new Shader(device, FileSystem.Open("chrome-shp.fx"));
|
||||
WorldSpriteShader.Quality = ShaderQuality.High;
|
||||
|
||||
sh = new SpriteHelper(device);
|
||||
fhDebug = new FontHelper(device, "Tahoma", 10, false);
|
||||
fhTitle = new FontHelper(device, "Tahoma", 10, true);
|
||||
//sh = new SpriteHelper(device);
|
||||
//fhDebug = new FontHelper(device, "Tahoma", 10, false);
|
||||
//fhTitle = new FontHelper(device, "Tahoma", 10, true);
|
||||
}
|
||||
|
||||
public GraphicsDevice Device { get { return device; } }
|
||||
@@ -47,7 +46,7 @@ namespace OpenRa.Graphics
|
||||
public void BeginFrame(float2 r1, float2 r2, float2 scroll)
|
||||
{
|
||||
device.Begin();
|
||||
device.Clear(0, Surfaces.Color);
|
||||
device.Clear(Color.Black);
|
||||
|
||||
SpriteShader.SetValue("Palette", PaletteTexture);
|
||||
SpriteShader.SetValue("Scroll", scroll);
|
||||
@@ -62,60 +61,58 @@ namespace OpenRa.Graphics
|
||||
device.Present();
|
||||
}
|
||||
|
||||
public void DrawBatch<T>(FvfVertexBuffer<T> vertices, IndexBuffer indices,
|
||||
public void DrawBatch<T>(VertexBuffer<T> vertices, IndexBuffer indices,
|
||||
Range<int> vertexRange, Range<int> indexRange, Texture texture, PrimitiveType type, Shader shader)
|
||||
where T : struct
|
||||
{
|
||||
shader.SetValue("DiffuseTexture", texture);
|
||||
shader.Commit();
|
||||
|
||||
vertices.Bind(0);
|
||||
vertices.Bind();
|
||||
indices.Bind();
|
||||
|
||||
device.DrawIndexedPrimitives(type,
|
||||
vertexRange, indexRange);
|
||||
device.DrawIndexedPrimitives(type, vertexRange, indexRange);
|
||||
|
||||
PerfHistory.Increment("batches", 1);
|
||||
}
|
||||
|
||||
public void DrawBatch<T>(FvfVertexBuffer<T> vertices, IndexBuffer indices,
|
||||
public void DrawBatch<T>(VertexBuffer<T> vertices, IndexBuffer indices,
|
||||
int vertexPool, int numPrimitives, Texture texture, PrimitiveType type)
|
||||
where T : struct
|
||||
{
|
||||
SpriteShader.SetValue("DiffuseTexture", texture);
|
||||
SpriteShader.Commit();
|
||||
|
||||
vertices.Bind(0);
|
||||
vertices.Bind();
|
||||
indices.Bind();
|
||||
|
||||
device.DrawIndexedPrimitives(type,
|
||||
vertexPool, numPrimitives);
|
||||
device.DrawIndexedPrimitives(type, vertexPool, numPrimitives);
|
||||
|
||||
PerfHistory.Increment("batches", 1);
|
||||
}
|
||||
|
||||
public void DrawText(string text, int2 pos, Color c)
|
||||
{
|
||||
sh.Begin();
|
||||
fhDebug.Draw(sh, text, pos.X, pos.Y, c.ToArgb());
|
||||
sh.End();
|
||||
//sh.Begin();
|
||||
//fhDebug.Draw(sh, text, pos.X, pos.Y, c.ToArgb());
|
||||
//sh.End();
|
||||
}
|
||||
|
||||
public void DrawText2(string text, int2 pos, Color c)
|
||||
{
|
||||
sh.Begin();
|
||||
fhTitle.Draw(sh, text, pos.X, pos.Y, c.ToArgb());
|
||||
sh.End();
|
||||
//sh.Begin();
|
||||
//fhTitle.Draw(sh, text, pos.X, pos.Y, c.ToArgb());
|
||||
//sh.End();
|
||||
}
|
||||
|
||||
public int2 MeasureText(string text)
|
||||
{
|
||||
return new int2(fhDebug.MeasureText(sh, text));
|
||||
return new int2(20,20);//fhDebug.MeasureText(sh, text));
|
||||
}
|
||||
|
||||
public int2 MeasureText2(string text)
|
||||
{
|
||||
return new int2(fhTitle.MeasureText(sh, text));
|
||||
return new int2(20,20);//fhTitle.MeasureText(sh, text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user