当前位置: 首页>>代码示例>>C#>>正文


C# IDrawDevice类代码示例

本文整理汇总了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) });
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:35,代码来源:DebugObject.cs

示例2: Draw

        public override void Draw(IDrawDevice device)
        {
            var mainClr = RetrieveMainColor();

            PrepareVertices(device, mainClr);
            device.AddVertices(sharedMat, VertexMode.Quads, _vertices);
        }
开发者ID:BraveSirAndrew,项目名称:DublinGamecraft4,代码行数:7,代码来源:SnowSkirt.cs

示例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));
 }
开发者ID:ninja2003,项目名称:duality,代码行数:7,代码来源:DefaultRendererVisibilityStrategy.cs

示例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;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:32,代码来源:BuiltinShaderFields.cs

示例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;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:25,代码来源:DefaultRendererVisibilityStrategy.cs

示例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;
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:7,代码来源:GameOverScreen.cs

示例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);
        }
开发者ID:SirePi,项目名称:duality,代码行数:26,代码来源:LightingSpriteRenderer.cs

示例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;
 }
开发者ID:generatives,项目名称:Magic-Game,代码行数:8,代码来源:UIManager.cs

示例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);
		}
开发者ID:Narinyir,项目名称:DualityOgvPlayerPlugin,代码行数:8,代码来源:OgvDrawTechnique.cs

示例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();
                    }
                }
            }
        }
开发者ID:SirePi,项目名称:duality,代码行数:58,代码来源:VisualLogRenderer.cs

示例11: Draw

 public void Draw(IDrawDevice device)
 {
     Canvas canvas = new Canvas(device);
     if(baseControl.NeedsLayout)
     {
         baseControl.Layout();
     }
     baseControl.Draw(canvas);
 }
开发者ID:generatives,项目名称:Magic-Game,代码行数:9,代码来源:UIManager.cs

示例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);
        }
开发者ID:gitMaxim,项目名称:duality,代码行数:13,代码来源:LightingTechnique.cs

示例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;
		}
开发者ID:Andrea,项目名称:duality-withsvn-history,代码行数:13,代码来源:GraphicsHelpers.cs

示例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);
			}
		}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:14,代码来源:MouseCursorRenderer.cs

示例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);
                        }
                    }
                }
            }
        }
开发者ID:generatives,项目名称:Magic-Game,代码行数:49,代码来源:EnvironmentRenderer.cs


注:本文中的IDrawDevice类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。