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


C# GraphicsDevice类代码示例

本文整理汇总了C#中GraphicsDevice的典型用法代码示例。如果您正苦于以下问题:C# GraphicsDevice类的具体用法?C# GraphicsDevice怎么用?C# GraphicsDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GraphicsDevice类属于命名空间,在下文中一共展示了GraphicsDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadingScreen

		/// <summary>
		/// The constructor is private: loading screens should
		/// be activated via the static Load method instead.
		/// </summary>
		private LoadingScreen (ScreenManager screenManager,bool loadingIsSlow, 
				GameScreen[] screensToLoad)
			{
			this.loadingIsSlow = loadingIsSlow;
			this.screensToLoad = screensToLoad;

			TransitionOnTime = TimeSpan.FromSeconds (0.5);

			// If this is going to be a slow load operation, create a background
			// thread that will update the network session and draw the load screen
			// animation while the load is taking place.
			if (loadingIsSlow) {
				backgroundThread = new Thread (BackgroundWorkerThread);
				backgroundThreadExit = new ManualResetEvent (false);

				graphicsDevice = screenManager.GraphicsDevice;

				// Look up some services that will be used by the background thread.
				IServiceProvider services = screenManager.Game.Services;

				networkSession = (NetworkSession)services.GetService (
							typeof(NetworkSession));

				messageDisplay = (IMessageDisplay)services.GetService (
							typeof(IMessageDisplay));
			}
		}
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:31,代码来源:LoadingScreen.cs

示例2: getMouseWorldPosition

        /// <summary>
        /// Checks the mouse's position set in the in-game world plane.
        /// </summary>
        /// <param name="mousePosition">Mouse's position on screen</param>
        /// <param name="camera">Camera object</param>
        /// <param name="device">Graphics device used in rendering</param>
        /// <returns></returns>
        public static Vector3 getMouseWorldPosition(Vector2 mousePosition,CameraAndLights camera,GraphicsDevice device)
        {
            Vector3 nearsource = new Vector3(mousePosition,0f);
            Vector3 farsource = new Vector3(mousePosition,CameraAndLights.nearClip);

            Vector3 nearPoint = device.Viewport.Unproject(nearsource,
                                                          camera.projectionMatrix,
                                                          camera.viewMatrix,
                                                          Matrix.Identity);

            Vector3 farPoint = device.Viewport.Unproject(farsource,
                                                         camera.projectionMatrix,
                                                         camera.viewMatrix,
                                                         Matrix.Identity);

            // Create a ray from the near clip plane to the far clip plane.
            Vector3 direction = farPoint - nearPoint;
            direction.Normalize();
            Ray pickRay = new Ray(nearPoint,direction);

            Plane floor = new Plane(new Vector3(0f,1f,0f),0f);

            float denominator = Vector3.Dot(floor.Normal,pickRay.Direction);
            float numerator = Vector3.Dot(floor.Normal,pickRay.Position) + floor.D;
            float dist = -(numerator / denominator);

            Vector3 mouseWorldPos = nearPoint + direction * dist;

            return mouseWorldPos * new Vector3(1f,0f,1f);
        }
开发者ID:ArghyV,项目名称:Peliohjelmointi-s2011,代码行数:37,代码来源:Input.cs

示例3: Player

        /// <summary>
        /// Player constructor.
        /// </summary>
        /// <param name="color"></param>
        public Player(Alliance alliance, Color color, Point startLocation)
        {
            Game1.GetInstance().players.AddLast(this);
            this.device = Game1.GetInstance().GraphicsDevice;
            this.alliance = alliance;
            this.startLocation = startLocation;
            if (!this.alliance.members.Contains(this)) this.alliance.members.AddLast(this);
            this.color = color;

            selectionTex = Game1.GetInstance().Content.Load<Texture2D>("Selection");
            selectedTex = Game1.GetInstance().Content.Load<Texture2D>("Selected");

            units = new CustomArrayList<Unit>();
            buildings = new CustomArrayList<Building>();
            hud = new HUD(this, color);
            resources = 100000;

            meleeStore = new MeleeStore(this);
            rangedStore = new RangedStore(this);
            fastStore = new FastStore(this);

            arrowManager = new ArrowManager();

            lightTexture = Game1.GetInstance().Content.Load<Texture2D>("Fog/Light");

            MouseManager.GetInstance().mouseClickedListeners += ((MouseClickListener)this).OnMouseClick;
            MouseManager.GetInstance().mouseReleasedListeners += ((MouseClickListener)this).OnMouseRelease;
            MouseManager.GetInstance().mouseMotionListeners += ((MouseMotionListener)this).OnMouseMotion;
            MouseManager.GetInstance().mouseDragListeners += ((MouseMotionListener)this).OnMouseDrag;
        }
开发者ID:Wotuu,项目名称:RTS_XNA_v2,代码行数:34,代码来源:Player.cs

示例4: APNGFrame

        internal APNGFrame(GraphicsDevice graphicsDevice, Frame frame)
        {
            if (frame.fcTLChunk != null)
            {
                X = (int) frame.fcTLChunk.XOffset;
                Y = (int) frame.fcTLChunk.YOffset;
                Width = (int) frame.fcTLChunk.Width;
                Height = (int) frame.fcTLChunk.Height;
                BlendOp = frame.fcTLChunk.BlendOp;
                DisposeOp = frame.fcTLChunk.DisposeOp;
                DelayTime = new TimeSpan(
                    TimeSpan.TicksPerSecond*frame.fcTLChunk.DelayNum/frame.fcTLChunk.DelayDen);
            }
            else
            {
                X = 0;
                Y = 0;
                Width = frame.IHDRChunk.Width;
                Height = frame.IHDRChunk.Height;
                BlendOp = BlendOps.APNGBlendOpSource;
                DisposeOp = DisposeOps.APNGDisposeOpNone;
                DelayTime = TimeSpan.Zero;
            }

            // frame.GetStream() is not seekable, so we build a new MemoryStream.
            FrameTexture = Texture2D.FromStream(
                graphicsDevice, new MemoryStream(frame.GetStream().ToArray()));
            MultiplyAlpha(FrameTexture);
        }
开发者ID:xupefei,项目名称:EAGSS,代码行数:29,代码来源:APNGFrame.cs

示例5: DrawObjects

        public override void DrawObjects(GraphicsDevice graphicDevice, SpriteBatch spriteBatch, ContentManager content)
        {
            graphicDevice.Clear(Color.CornflowerBlue);
            SpriteFont newFont = content.Load<SpriteFont>(@"Fonts/Text");

            spriteBatch.Begin();

            this.controlScreenBackgroundPosition = new Vector2(0, 0);
            spriteBatch.Draw(this.controlScreenBackgroundTexture, this.controlScreenBackgroundPosition, Color.White);

            if (this.controlScreenItems.Count < 1)
            {
                // Back planket and text;
                this.buttonPosition = new Vector2(840, 660);
                this.controlScreenItems.Add(new MenuItems(this.button, this.buttonPosition, "Back", newFont, false));
            }

            this.controlScreenItems[this.selectedEntry].Selected = true;
            foreach (var item in this.controlScreenItems)
            {
                item.DrawMenuItems(spriteBatch, new Color(248, 218, 127));
            }

            this.DrawCursor(spriteBatch);
            spriteBatch.End();
        }
开发者ID:penjurov,项目名称:TeamGeorgeOrwell,代码行数:26,代码来源:ControlScreen.cs

示例6: CreateWhitePixel

        private static Texture2D CreateWhitePixel(GraphicsDevice graphicsDevice)
        {
            whitePixel = new Texture2D(graphicsDevice, 1, 1);
            whitePixel.SetData(new[] { Color.White });

            return whitePixel;
        }
开发者ID:elefantstudio-se,项目名称:tiny-tile-editor,代码行数:7,代码来源:Utility.cs

示例7: Draw

        public void Draw(GraphicsDevice gd)
        {
            drawEffect.World = Matrix.CreateTranslation(Position);

            drawEffect.DiffuseColor = new Vector3(1f, 1f - hitAlpha, 1f - hitAlpha);
            foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                AnimChunk c = shipSprite.AnimChunks[0];
                if (c == null) continue;

                if (c == null || c.VertexArray == null || c.VertexArray.Length == 0) continue;
                gd.DrawUserIndexedPrimitives<VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);

            }

            drawEffect.World = Matrix.CreateScale(0.75f) * (Matrix.CreateRotationX(orbRotation.X) * Matrix.CreateRotationY(orbRotation.Y) * Matrix.CreateRotationZ(orbRotation.Z)) * Matrix.CreateTranslation(orbPosition);

            drawEffect.DiffuseColor = Color.White.ToVector3();

            foreach (EffectPass pass in drawEffect.CurrentTechnique.Passes)
            {
                pass.Apply();

                AnimChunk c = shipSprite.AnimChunks[1];
                if (c == null) continue;

                if (c == null || c.VertexArray == null || c.VertexArray.Length == 0) continue;
                gd.DrawUserIndexedPrimitives<VertexPositionNormalColor>(PrimitiveType.TriangleList, c.VertexArray, 0, c.VertexArray.Length, c.IndexArray, 0, c.VertexArray.Length / 2);
            }
        }
开发者ID:GarethIW,项目名称:VoxelShooter,代码行数:32,代码来源:Hero.cs

示例8: CylinderPrimitive

        /// <summary>
        /// Constructs a new cylinder primitive,
        /// with the specified size and tessellation level.
        /// </summary>
        public CylinderPrimitive(GraphicsDevice graphicsDevice,
            float height, float radius, int tessellation)
        {
            if (tessellation < 3)
                throw new ArgumentOutOfRangeException("tessellation");

            height /= 2;

            // Create a ring of triangles around the outside of the cylinder.
            for (int i = 0; i < tessellation; i++)
            {
                Vector3 normal = GetCircleVector(i, tessellation);

                AddVertex(normal * radius + Vector3.Up * height, normal);
                AddVertex(normal * radius + Vector3.Down * height, normal);

                AddIndex(i * 2);
                AddIndex(i * 2 + 1);
                AddIndex((i * 2 + 2) % (tessellation * 2));

                AddIndex(i * 2 + 1);
                AddIndex((i * 2 + 3) % (tessellation * 2));
                AddIndex((i * 2 + 2) % (tessellation * 2));
            }

            // Create flat triangle fan caps to seal the top and bottom.
            CreateCap(tessellation, height, radius, Vector3.Up);
            CreateCap(tessellation, height, radius, Vector3.Down);

            InitializePrimitive(graphicsDevice);
        }
开发者ID:reidyd,项目名称:jitterphysics,代码行数:35,代码来源:CylinderPrimitive.cs

示例9: Event

        public Event(SpriteBatch _s, GraphicsDevice _g,SpriteFont _font)
        {
            s = _s;
            g = _g;
            font = _font;

            posBGI.X = 0;
            posBGI.Y = 0;
            posLeft0.X = 0;
            posLeft0.Y = 10;
            posLeft1.X = 60;
            posLeft1.Y = 10;
            posRight0.X = 480;
            posRight0.Y = 10;
            posRight1.X = 520;
            posRight1.Y = 10;
            posFrame.X = 10;
            posFrame.Y = 340;
            posName.X = 100;
            posName.Y = 355;
            posTalk.X = 50;
            posTalk.Y = 400;

            serif = new List<string>();
            Stream stream;
             stream = File.OpenRead("images/hb1.png");
            imgBGI = Texture2D.FromStream(g, stream);

             stream = File.OpenRead("images/sowaku.png");
             imgFrame = Texture2D.FromStream(g, stream);
        }
开发者ID:TowerTin,项目名称:SourceCode,代码行数:31,代码来源:Event.cs

示例10: ColorVertex

 public virtual void ColorVertex(GraphicsDevice gd, int index, Vector2 texturePosition)
 {
     VertexPositionNormalTexture v = vertices[index];
     v.TextureCoordinate = texturePosition;
     vertices[index] = v;
     InitializeVertexBuffer(gd);
 }
开发者ID:odinhaus,项目名称:Genesis,代码行数:7,代码来源:CustomGeometricPrimitive.cs

示例11: LightmapDrawBuffer

        /// <summary>
        /// Initializes a new instance of the <see cref="LightmapDrawBuffer"/> class.
        /// </summary>
        /// <param name="device">The graphics device.</param>
        public LightmapDrawBuffer(GraphicsDevice device)
        {
            this.device = device;

            // this.indices = new List<int>();
            this.vertices = new List<HullVertex>();
        }
开发者ID:AndrewHackler,项目名称:shooter,代码行数:11,代码来源:LightmapDrawBuffer.cs

示例12: Draw

        public override void Draw(GraphicsDevice device, Camera camera)
        {
            game.GraphicsDevice.BlendState = BlendState.AlphaBlend;

            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);
            game.GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.World = mesh.ParentBone.Transform * GetWorld();
                    effect.View = camera.view;
                    effect.Projection = camera.projection;
                    effect.TextureEnabled = true;
                    effect.Texture = tex;
                    effect.Alpha = alpha;

                    //trying to get lighting to work, but so far the model just shows up as pure black - it was exported with a green blinn shader
                    //effect.EnableDefaultLighting(); //did not work
                    effect.LightingEnabled = true;

                }
                mesh.Draw();
            }
        }
开发者ID:Thinny-Hendrix,项目名称:MoonCow,代码行数:27,代码来源:AstCloudParticle.cs

示例13: Draw

 public override void Draw(double elapsedSeconds, GraphicsDevice device)
 {
     sb.Begin();
     gui.Draw(device, sb, elapsedSeconds);
     sb.End();
     base.Draw(elapsedSeconds, device);
 }
开发者ID:salloo,项目名称:Samurai,代码行数:7,代码来源:CreateGameScreen.cs

示例14: AutoInitialize

        //===========================================================
        // Structures and Variables
        //===========================================================

        //===========================================================
        // Overridden Particle System Functions
        //===========================================================

        //===========================================================
        // Initialization Functions
        //===========================================================
        public override void AutoInitialize(GraphicsDevice cGraphicsDevice, ContentManager cContentManager, SpriteBatch cSpriteBatch)
        {
            InitializeSpriteParticleSystem(cGraphicsDevice, cContentManager, 1000, 50000, "Textures/Smoke");
            LoadParticleSystem();
            Emitter.ParticlesPerSecond = 200;
            Name = "Dot";
        }
开发者ID:Imortilize,项目名称:Psynergy-Engine,代码行数:18,代码来源:DotPS.cs

示例15: TrophyScreen

 public TrophyScreen(GameWorld3D game)
 {
     _game           = game.Game;
     _graphicsDevice = game.GraphicsDevice;
     _gameWorld3D    = game;
     Initialize();
 }
开发者ID:Gerjo,项目名称:Serious-game,代码行数:7,代码来源:TrophyScreen.cs


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