本文整理汇总了C#中IDrawDevice类的典型用法代码示例。如果您正苦于以下问题:C# IDrawDevice类的具体用法?C# IDrawDevice怎么用?C# IDrawDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDrawDevice类属于命名空间,在下文中一共展示了IDrawDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(IDrawDevice device)
{
// Perform Camera space transformation
Vector3 posBefore = this.GameObj.Transform.Pos;
Vector3 posTemp = posBefore;
float scaleTemp = 1.0f;
device.PreprocessCoords(this, ref posTemp, ref scaleTemp);
// Draw debug text
VertexC1P3T2[] textVertices;
textVertices = null;
Font.GenericMonospace10.Res.EmitTextVertices(
string.Format("Position (world): {0:0}, {1:0}, {2:0}", posBefore.X, posBefore.Y, posBefore.Z),
ref textVertices, posTemp.X, posTemp.Y, posTemp.Z);
device.AddVertices(Font.GenericMonospace10.Res.Material, BeginMode.Quads, textVertices);
textVertices = null;
Font.GenericMonospace10.Res.EmitTextVertices(
string.Format("Position (cam): {0:0}, {1:0}, {2:0}", posTemp.X, posTemp.Y, posTemp.Z),
ref textVertices, posTemp.X, posTemp.Y + 10, posTemp.Z);
device.AddVertices(Font.GenericMonospace10.Res.Material, BeginMode.Quads, textVertices);
textVertices = null;
Font.GenericMonospace10.Res.EmitTextVertices(
string.Format("Scale: {0:F}", scaleTemp),
ref textVertices, posTemp.X, posTemp.Y + 20, posTemp.Z);
device.AddVertices(Font.GenericMonospace10.Res.Material, BeginMode.Quads, textVertices);
// Draw position indicator
device.AddVertices(new BatchInfo(DrawTechnique.Alpha, ColorRgba.Red.WithAlpha(0.25f)), BeginMode.Quads, new VertexP3[] {
new VertexP3(posTemp.X - 50.0f * scaleTemp, posTemp.Y - 50.0f * scaleTemp, posTemp.Z),
new VertexP3(posTemp.X + 50.0f * scaleTemp, posTemp.Y - 50.0f * scaleTemp, posTemp.Z),
new VertexP3(posTemp.X + 50.0f * scaleTemp, posTemp.Y + 50.0f * scaleTemp, posTemp.Z),
new VertexP3(posTemp.X - 50.0f * scaleTemp, posTemp.Y + 50.0f * scaleTemp, posTemp.Z) });
}
示例2: Draw
public override void Draw(IDrawDevice device)
{
var mainClr = RetrieveMainColor();
PrepareVertices(device, mainClr);
device.AddVertices(sharedMat, VertexMode.Quads, _vertices);
}
示例3: QueryVisibleRenderers
public IEnumerable<ICmpRenderer> QueryVisibleRenderers(IDrawDevice device)
{
if (this.renderers == null)
return Enumerable.Empty<ICmpRenderer>();
else
return this.renderers.Where(r => (r as Component).Active && r.IsVisible(device));
}
示例4: TryGetValue
/// <summary>
/// Retrieves the value of a builtin shader variable using the index retrieved by <see cref="GetIndex"/>.
/// </summary>
/// <param name="currentDevice"></param>
/// <param name="index"></param>
/// <param name="value"></param>
/// <returns></returns>
public static bool TryGetValue(IDrawDevice currentDevice, int index, ref float[] value)
{
int size = 1;
switch (index)
{
case InvalidIndex: return false;
default: size = 1; break;
case 4: size = 3; break;
}
value = (value != null && value.Length == size) ? value : new float[size];
switch (index)
{
case 0: value[0] = (float)Time.MainTimer.TotalSeconds; return true;
case 1: value[0] = (float)Time.GameTimer.TotalSeconds; return true;
case 2: value[0] = (float)Time.FrameCount; return true;
case 3: value[0] = currentDevice.FocusDist; return true;
case 4: value[0] = currentDevice.RefCoord.X;
value[1] = currentDevice.RefCoord.Y;
value[2] = currentDevice.RefCoord.Z; return true;
case 5: value[0] = currentDevice.Perspective == PerspectiveMode.Parallax ? 1.0f : 0.0f; return true;
}
return false;
}
示例5: QueryVisibleRenderers
public void QueryVisibleRenderers(IDrawDevice device, RawList<ICmpRenderer> targetList)
{
// Empty the cached list of visible renderers
targetList.Count = 0;
targetList.Reserve(this.totalRendererCount);
// Copy references to all renderers that are visible to the target device
int visibleCount = 0;
ICmpRenderer[] targetData = targetList.Data;
foreach (var pair in this.renderersByType)
{
ICmpRenderer[] data = pair.Value.Data;
for (int i = 0; i < data.Length; i++)
{
if (i >= pair.Value.Count) break;
if ((data[i] as Component).Active && data[i].IsVisible(device))
{
targetData[visibleCount] = data[i];
visibleCount++;
}
}
}
targetList.Count = visibleCount;
}
示例6:
bool ICmpRenderer.IsVisible(IDrawDevice device)
{
// Only render when in screen overlay mode and the visibility mask is non-empty.
return
(device.VisibilityMask & VisibilityFlag.AllGroups) != VisibilityFlag.None &&
(device.VisibilityMask & VisibilityFlag.ScreenOverlay) != VisibilityFlag.None;
}
示例7: Draw
public override void Draw(IDrawDevice device)
{
Texture mainTex = this.RetrieveMainTex();
ColorRgba mainClr = this.RetrieveMainColor();
DrawTechnique tech = this.RetrieveDrawTechnique();
Rect uvRect;
if (mainTex != null)
{
if (this.rectMode == UVMode.WrapBoth)
uvRect = new Rect(mainTex.UVRatio.X * this.rect.W / mainTex.PixelWidth, mainTex.UVRatio.Y * this.rect.H / mainTex.PixelHeight);
else if (this.rectMode == UVMode.WrapHorizontal)
uvRect = new Rect(mainTex.UVRatio.X * this.rect.W / mainTex.PixelWidth, mainTex.UVRatio.Y);
else if (this.rectMode == UVMode.WrapVertical)
uvRect = new Rect(mainTex.UVRatio.X, mainTex.UVRatio.Y * this.rect.H / mainTex.PixelHeight);
else
uvRect = new Rect(mainTex.UVRatio.X, mainTex.UVRatio.Y);
}
else
uvRect = new Rect(1.0f, 1.0f);
this.PrepareVerticesLight(ref this.verticesLight, device, mainClr, uvRect, tech);
if (this.customMat != null) device.AddVertices(this.customMat, VertexMode.Quads, this.verticesLight);
else device.AddVertices(this.sharedMat, VertexMode.Quads, this.verticesLight);
}
示例8: IsVisible
public bool IsVisible(IDrawDevice device)
{
return
// Make sure the ScreenOverlay flag is set
(device.VisibilityMask & VisibilityFlag.ScreenOverlay) != VisibilityFlag.None &&
// Make sure some other flag is also set.
(device.VisibilityMask & ~VisibilityFlag.ScreenOverlay) != VisibilityFlag.None;
}
示例9: PrepareRendering
protected override void PrepareRendering(IDrawDevice device, BatchInfo material)
{
base.PrepareRendering(device, material);
material.SetTexture("mainTex", TextureOne);
material.SetTexture("samp1", TextureTwo);
material.SetTexture("samp2", TextureThree);
}
示例10: Canvas
void ICmpRenderer.Draw(IDrawDevice device)
{
if (device.VisibilityMask.HasFlag(VisibilityFlag.ScreenOverlay))
{
Canvas target = new Canvas(device, this.vertexBufferScreen);
target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, ColorRgba.White));
foreach (VisualLog log in VisualLog.All)
{
if (!log.Visible) continue;
if (log.BaseColor.A == 0) continue;
if ((log.VisibilityGroup & device.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None) continue;
target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, log.BaseColor));
foreach (VisualLogEntry logEntry in log.Entries)
{
if (logEntry.Anchor != VisualLogAnchor.Screen) continue;
target.PushState();
if (logEntry.LifetimeAsAlpha)
target.State.ColorTint = new ColorRgba(1.0f, logEntry.LifetimeRatio);
else
target.State.ColorTint = ColorRgba.White;
logEntry.Draw(target);
target.PopState();
}
}
}
else
{
Canvas target = new Canvas(device, this.vertexBufferWorld);
target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, ColorRgba.White));
target.State.ZOffset = -1;
foreach (VisualLog log in VisualLog.All)
{
if (!log.Visible) continue;
if (log.BaseColor.A == 0) continue;
if ((log.VisibilityGroup & device.VisibilityMask & VisibilityFlag.AllGroups) == VisibilityFlag.None) continue;
target.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, log.BaseColor));
foreach (VisualLogEntry logEntry in log.Entries)
{
if (logEntry.Anchor == VisualLogAnchor.Screen) continue;
target.PushState();
target.State.ZOffset += logEntry.DepthOffset;
target.State.ColorTint = new ColorRgba(1.0f, logEntry.LifetimeRatio);
if (logEntry.Anchor == VisualLogAnchor.Object && logEntry.AnchorObj != null && logEntry.AnchorObj.Transform != null)
{
Transform anchorTransform = logEntry.AnchorObj.Transform;
logEntry.Draw(target, anchorTransform.Pos, anchorTransform.Angle, anchorTransform.Scale);
}
else
{
logEntry.Draw(target);
}
target.PopState();
}
}
}
}
示例11: Draw
public void Draw(IDrawDevice device)
{
Canvas canvas = new Canvas(device);
if(baseControl.NeedsLayout)
{
baseControl.Layout();
}
baseControl.Draw(canvas);
}
示例12: PrepareRendering
public override void PrepareRendering(IDrawDevice device, BatchInfo material)
{
base.PrepareRendering(device, material);
Vector3 camPos = device.RefCoord;
float camRefDist = MathF.Abs(device.FocusDist);
// Don't pass RefDist, see note in Light.cs
material.SetUniform("_camRefDist", camRefDist);
material.SetUniform("_camWorldPos", camPos.X, camPos.Y, camPos.Z);
DynamicLighting.Light.SetupLighting(device, material);
}
示例13: GrabScreenshot
public static Bitmap GrabScreenshot(IDrawDevice device)
{
if (GraphicsContext.CurrentContext == null)
throw new GraphicsContextMissingException();
var bmp = new Bitmap((int) device.TargetSize.X, (int)device.TargetSize.Y);
var data = bmp.LockBits(new Rectangle(0, 0, (int) device.TargetSize.X, (int) device.TargetSize.Y), ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
GL.ReadPixels(0, 0, (int) device.TargetSize.X, (int) device.TargetSize.Y, PixelFormat.Bgr, PixelType.UnsignedByte, data.Scan0);
bmp.UnlockBits(data);
// bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
return bmp;
}
示例14: Canvas
void ICmpRenderer.Draw(IDrawDevice device)
{
Canvas canvas = new Canvas(device);
// Draw the mouse cursor when available
if (DualityApp.Mouse.IsAvailable)
{
canvas.State.ColorTint = ColorRgba.White;
canvas.FillCircle(
DualityApp.Mouse.X,
DualityApp.Mouse.Y,
2);
}
}
示例15: Draw
public void Draw(IDrawDevice device)
{
var triangles = env.Triangles;
var triangleSideLength = env.TriangleSideLength;
Canvas canvas = new Canvas(device);
Vector2[][] vectors = new Vector2[4][];
vectors[0] = new Vector2[3];
vectors[0][0] = new Vector2(-(triangleSideLength / 2), -(triangleSideLength / 2));
vectors[0][1] = new Vector2((triangleSideLength / 2), -(triangleSideLength / 2));
vectors[0][2] = new Vector2(0, 0);
vectors[1] = new Vector2[3];
vectors[1][0] = new Vector2((triangleSideLength / 2), -(triangleSideLength / 2));
vectors[1][1] = new Vector2((triangleSideLength / 2), (triangleSideLength / 2));
vectors[1][2] = new Vector2(0, 0);
vectors[2] = new Vector2[3];
vectors[2][0] = new Vector2((triangleSideLength / 2), (triangleSideLength / 2));
vectors[2][1] = new Vector2(-(triangleSideLength / 2), (triangleSideLength / 2));
vectors[2][2] = new Vector2(0, 0);
vectors[3] = new Vector2[3];
vectors[3][0] = new Vector2(-(triangleSideLength / 2), (triangleSideLength / 2));
vectors[3][1] = new Vector2(-(triangleSideLength / 2), -(triangleSideLength / 2));
vectors[3][2] = new Vector2(0, 0);
BatchInfo[] infos = new BatchInfo[4];
infos[0] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.Red, null);
infos[1] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.Blue, null);
infos[2] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.White, null);
infos[3] = new BatchInfo(DrawTechnique.Alpha, ColorRgba.Green, null);
for (int x = 0; x < triangles.GetLength(0); x++)
{
for (int y = 0; y < triangles.GetLength(1); y++)
{
for (int i = 0; i < triangles.GetLength(2); i++)
{
canvas.State.SetMaterial(infos[i]);
if(true/*triangles[x,y,i] != null*/)
{
canvas.FillPolygon(vectors[i], triangleSideLength / 2 + triangleSideLength * x,
triangleSideLength / 2 + triangleSideLength * y);
}
}
}
}
}