Ok, so I've made changes to Delta.Rendering.Basics.Drawing that, let's say for the sake of argument, the Delta Engine team do not wish to incorporate into Delta Engine.
How would I get the build process to use my local version as opposed to the standard Delta Engine DLL?
I've tried bringing the various classes into my own Project (still keeping the Delta Engine namespace), but, as I expected, they run up against scoping issues - with various classes and methods internal to Delta Engine being inaccessible outside of it - and with some parts of Delta Engine still closed source I can't get round that.
How is it anticipated that I should be dealing with this issue? Thinking about it now, if I move my project entirely inside of the Delta Engine solution, would that work? Seems overkill if there's an easier way, though - and I could imagine the build engine still getting tripped up...
---
Btw, the changes I've made may or may not be useful to others. I don't know if it meets with the vision for RenderLayer going forwards...?
Basically, instead of one instance of DrawManager, there is an array of instances (created on demand) with potentially one DrawManager per RenderLayer:
ie. Instead of
Code:
private static DrawManager instance
internal static DrawManager Instance
{
get
{
if (instance == null)
{
// Needs to be created via factory to make sure we only do this once
instance = Factory.Create<DrawManager>();
}
return instance;
} // get
}
It goes:
Code:
private static DrawManager[] instances;
public static DrawManager Instance
{
get
{
return Instances((RenderLayer)((MaterialManager.layers.Length - 1) / BaseMaterial.NumberOfBlendModes));
} // get
}
public static DrawManager Instances(RenderLayer drawLayer)
{
// If we have not yet created our DrawManager array, do so now
if (instances == null) instances = new DrawManager[(MaterialManager.layers.Length / BaseMaterial.NumberOfBlendModes)];
// If we have not yet created our DrawManager instance for this renderlayer, do so now
if (instances[(int)drawLayer] == null) instances[(int)drawLayer] = Factory.Create<DrawManager>(drawLayer);
// Return the appropriate DrawManager
return instances[(int)drawLayer];
}
With the DrawManager constructor accepting the required RenderLayer
Code:
protected DrawManager(RenderLayer drawLayer)
: base("DrawManager", typeof(MaterialManager))
{
try
{
// The line material is an empty material with just the shader.
// Note: 2D and 3D Positions are different in vertex data, both use
// pretty much the same shader, but we need to 2 materials anyway.
line2DMaterial = new Material((Texture)null, Shader.Create(
// Note: This even works for VertexCompression because the Content.xml
// does save the original shader flags, not the modified ones in the
// case the VertexFormat of the shader uses vertex compression!
ShaderFeatureFlags.Basic |
ShaderFeatureFlags.UI2D |
ShaderFeatureFlags.NoTexturing |
ShaderFeatureFlags.ColoredVertices))
{
// Make sure that we always see the lines and aren't hidden by any
// "normal" geometry because the lines are usually used as debug
// information
// DrawLayer = (RenderLayer)((MaterialManager.layers.Length - 1) /
// BaseMaterial.NumberOfBlendModes)
// Assign the prescribed draw layer
DrawLayer = drawLayer,
};
...
}
And with the various Drawing operations now overloaded to accept a RenderLayer parameter - and the draws themselves all using DrawManager.Instances(drawLayer) instead of DrawManager.Instance:
Code:
public static void DrawOutline(Rectangle rect, Color lineColor)
{
DrawOutline(rect, lineColor, (RenderLayer)((MaterialManager.layers.Length - 1) / BaseMaterial.NumberOfBlendModes));
}
public static void DrawOutline(Rectangle rect, Color lineColor, RenderLayer drawLayer)
{
// Skip if the drawArea is certainly outside of the quadratic space.
// Checking the screen area would work too, but is a little slower and
// won't exclude much more anyway.
if (rect.Left >= 1.0f ||
rect.Top >= 1.0f ||
rect.Left < -rect.Width ||
rect.Top < -rect.Height)
{
// Skip this material rendering, not visible this frame.
return;
}
DrawManager drawInstance = DrawManager.Instances(drawLayer);
Point topRight = rect.TopRight;
Point bottomRight = rect.BottomRight;
Point bottomLeft = rect.BottomLeft;
drawInstance.Draw2DLine(ref rect.TopLeft, ref topRight, ref lineColor);
drawInstance.Draw2DLine(ref topRight, ref bottomRight, ref lineColor);
drawInstance.Draw2DLine(ref bottomRight, ref bottomLeft, ref lineColor);
drawInstance.Draw2DLine(ref bottomLeft, ref rect.TopLeft, ref lineColor);
}
Edited by user Thursday, May 3, 2012 3:05:53 AM(UTC)
| Reason: Not specified