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


C# Graphics.GraphicsDevice类代码示例

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


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

示例1: CreateDevice

        private void CreateDevice(IntPtr windowHandle, int width, int height)
        {
            try
            {
                parameters = new PresentationParameters();

                parameters.BackBufferWidth = Math.Max(width, 1);
                parameters.BackBufferHeight = Math.Max(height, 1);
                parameters.BackBufferFormat = SurfaceFormat.Color;
                parameters.DepthStencilFormat = DepthFormat.Depth24;
                parameters.DeviceWindowHandle = windowHandle;
                parameters.PresentationInterval = PresentInterval.Immediate;
                parameters.IsFullScreen = false;

                graphicsDevice = new GraphicsDevice(
                    GraphicsAdapter.DefaultAdapter,
                    GraphicsProfile.Reach,
                    parameters);

                if (DeviceCreated != null)
                    DeviceCreated(this, EventArgs.Empty);

            }
            catch (Exception ex)
            {
                throw new ApplicationException("Failed to initialize GraphicsDeviceService. See inner exception for details.", ex);
            }
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:28,代码来源:GraphicsDeviceService.cs

示例2: TextureContext

        public TextureContext(GraphicsDevice graphicsDevice, Stream stream, bool premultiplyAlpha)
        {
            _texture = Texture2D.FromStream(graphicsDevice, stream);

            if (premultiplyAlpha)
                PremultiplyTexture(_texture);
        }
开发者ID:jaquadro,项目名称:MonoGdx,代码行数:7,代码来源:TextureContext.cs

示例3: Draw

 public override void Draw(GraphicsDevice device)
 {
     for (int i = 0; i < m_Elements.Count; i++)
     {
         m_Elements[i].Draw(device);
     }
 }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:7,代码来源:3DScene.cs

示例4: Reset

 public static unsafe void Reset(GraphicsDevice graphicsDevice, PresentationParameters parameters)
 {
     var fi = typeof(GraphicsDevice).GetField("pComPtr", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
     var ptr = fi.GetValue(graphicsDevice);
     var pComPtr = new IntPtr(System.Reflection.Pointer.Unbox(ptr));
     if (g_mdxAssembly == null) throw new ApplicationException("GraphicsDevice.Reset failed. Please install Managed DirectX from the Assault Wing web site.");
     var mdxDeviceType = g_mdxAssembly.GetType("Microsoft.DirectX.Direct3D.Device");
     var mdxPresentParametersType = g_mdxAssembly.GetType("Microsoft.DirectX.Direct3D.PresentParameters");
     var dev = Activator.CreateInstance(mdxDeviceType, pComPtr);
     dynamic dxParameters = new MDXPresentParameters(Activator.CreateInstance(mdxPresentParametersType));
     dxParameters.AutoDepthStencilFormat = parameters.DepthStencilFormat.ToD3D();
     dxParameters.BackBufferCount = 1;
     dxParameters.BackBufferFormat = parameters.BackBufferFormat.ToD3D();
     dxParameters.BackBufferHeight = parameters.BackBufferHeight;
     dxParameters.BackBufferWidth = parameters.BackBufferWidth;
     dxParameters.DeviceWindow = null;
     dxParameters.DeviceWindowHandle = parameters.DeviceWindowHandle;
     dxParameters.EnableAutoDepthStencil = false; // ???
     dxParameters.ForceNoMultiThreadedFlag = false; // ???
     dxParameters.FullScreenRefreshRateInHz = 0; // ??? should be 0 for windowed mode; in fullscreen mode take value from DisplayModeCollection
     dxParameters.MultiSample = GetMDXEnumValue("MultiSampleType", "None");
     dxParameters.MultiSampleQuality = 0;
     dxParameters.PresentationInterval = parameters.PresentationInterval.ToD3D();
     dxParameters.PresentFlag = GetMDXEnumValue("PresentFlag", "None"); // ???
     dxParameters.SwapEffect = GetMDXEnumValue("SwapEffect", "Flip"); // ??? see _parameters.RenderTargetUsage
     dxParameters.Windowed = !parameters.IsFullScreen;
     var resetMethod = mdxDeviceType.GetMethod("Reset");
     var mdxPresentParametersArray = Array.CreateInstance(mdxPresentParametersType, 1);
     mdxPresentParametersArray.SetValue(((MDXPresentParameters)dxParameters).WrappedValue, 0);
     resetMethod.Invoke(dev, new[] { mdxPresentParametersArray });
 }
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:31,代码来源:Direct3D.cs

示例5: TextTest

 public TextTest(IKernel kernel, GraphicsDevice device, ContentManager content)
     : base("Text Test", kernel)
 {
     _kernel = kernel;
     _device = device;
     _content = content;
 }
开发者ID:xoxota99,项目名称:Myre,代码行数:7,代码来源:TextTest.cs

示例6: SetConstantBuffers

        internal void SetConstantBuffers(GraphicsDevice device, int shaderProgram)
#endif
        {
            // If there are no constant buffers then skip it.
            if (_valid == 0)
                return;

            var valid = _valid;

            for (var i = 0; i < _buffers.Length; i++)
            {
                var buffer = _buffers[i];
                if (buffer != null)
                {
#if DIRECTX
                    buffer.Apply(device, _stage, i);
#elif OPENGL || PSM
                    buffer.Apply(device, shaderProgram);
#endif
                }

                // Early out if this is the last one.
                valid &= ~(1 << i);
                if (valid == 0)
                    return;
            }
        }
开发者ID:fragcastle,项目名称:MonoGame,代码行数:27,代码来源:ConstantBufferCollection.cs

示例7: Content

        /// <summary>
        /// Creates a new instance of Content.
        /// </summary>
        /// <param name="basePath">Path to client directory.</param>
        /// <param name="device">A GraphicsDevice instance.</param>
        private Content(string basePath, GraphicsDevice device)
        {
            this.BasePath = basePath;
            this.Device = device;

            Changes = new ChangeManager();

            UIGraphics = new UIGraphicsProvider(this);
            AvatarMeshes = new AvatarMeshProvider(this, Device);
            AvatarBindings = new AvatarBindingProvider(this);
            AvatarTextures = new AvatarTextureProvider(this, Device);
            AvatarSkeletons = new AvatarSkeletonProvider(this);
            AvatarAppearances = new AvatarAppearanceProvider(this);
            AvatarOutfits = new AvatarOutfitProvider(this);
            AvatarAnimations = new AvatarAnimationProvider(this);
            AvatarPurchasables = new AvatarPurchasables(this);
            AvatarHandgroups = new HandgroupProvider(this, Device);
            AvatarCollections = new AvatarCollectionsProvider(this);
            AvatarThumbnails = new AvatarThumbnailProvider(this, Device);

            WorldObjects = new WorldObjectProvider(this);
            WorldFloors = new WorldFloorProvider(this);
            WorldWalls = new WorldWallProvider(this);
            WorldObjectGlobals = new WorldGlobalProvider(this);
            WorldCatalog = new WorldObjectCatalog();

            Audio = new Audio(this);
            GlobalTuning = new Tuning(Path.Combine(basePath, "tuning.dat"));

            Init();
        }
开发者ID:RHY3756547,项目名称:FreeSO,代码行数:36,代码来源:Content.cs

示例8: ApplyState

 internal void ApplyState(GraphicsDevice device)
 {
   bool flag = device.GetRenderTargets().Length > 0;
   if (this.CullMode == CullMode.None)
   {
     GL.Disable(EnableCap.CullFace);
   }
   else
   {
     GL.Enable(EnableCap.CullFace);
     GL.CullFace(CullFaceMode.Back);
     if (this.CullMode == CullMode.CullClockwiseFace)
     {
       if (flag)
         GL.FrontFace(FrontFaceDirection.Cw);
       else
         GL.FrontFace(FrontFaceDirection.Ccw);
     }
     else if (flag)
       GL.FrontFace(FrontFaceDirection.Ccw);
     else
       GL.FrontFace(FrontFaceDirection.Cw);
   }
   if (this.FillMode == FillMode.Solid)
     GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
   else
     GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
   if (this.ScissorTestEnable)
     GL.Enable(EnableCap.ScissorTest);
   else
     GL.Disable(EnableCap.ScissorTest);
   GL.Enable(EnableCap.PolygonOffsetFill);
   GL.PolygonOffset(this.SlopeScaleDepthBias, this.DepthBias * 1E+07f);
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:34,代码来源:RasterizerState.cs

示例9: Renderer

 public Renderer(GraphicsDevice device, RenderState renderState)
 {
     RenderState  = renderState;
     Device = device;
     _effect = new BasicEffect(Device);
     _bufferedInstructions = new List<IEnumerable<RenderInstruction>>();
 }
开发者ID:Jaywd,项目名称:binary.fail.project.haumea,代码行数:7,代码来源:Renderer.cs

示例10: DrawAfter2D

 public void DrawAfter2D(GraphicsDevice gd, WorldState state)
 {
     gd.RenderState.CullMode = CullMode.CullCounterClockwiseFace;
     foreach (var avatar in Blueprint.Avatars){
         avatar.Draw(gd, state);
     }
 }
开发者ID:Blayer98,项目名称:Project-Dollhouse,代码行数:7,代码来源:World3D.cs

示例11: GraphicsManger

 public GraphicsManger(GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, ContentManager content)
 {
     Console.WriteLine("graphics manager initialized");
     GraphicsDevice = graphicsDevice;
     SpriteBatch = spriteBatch;
     Content = content;
 }
开发者ID:SFDStrandberg,项目名称:StarPunk,代码行数:7,代码来源:GraphicsManger.cs

示例12: DrawBefore2D

 public void DrawBefore2D(GraphicsDevice gd, WorldState state)
 {
     foreach (var avatar in Blueprint.Avatars)
     {
         avatar.Draw(gd, state);
     }
 }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:7,代码来源:World3D.cs

示例13: ResourceToTexture2D

 public static Texture2D ResourceToTexture2D(string resource, GraphicsDevice gd)
 {
     using (Stream stream = Assembly.GetCallingAssembly().GetManifestResourceStream(resource))
     {
         return Texture2D.FromStream(gd, stream);
     }
 }
开发者ID:KeviinSkyline,项目名称:Terraria-Map-Editor,代码行数:7,代码来源:WriteableBitmapEx.cs

示例14: Snowplow

 public Snowplow(GraphicsDevice device, Model model, VFXEffect effect)
     : base(device,model,effect)
 {
     _isDoubleSided["Circle"] = true;
     _isDoubleSided["Circle.004"] = true;
     _isDoubleSided["Circle.003"] = true;
 }
开发者ID:tornvall,项目名称:LaborationVFX,代码行数:7,代码来源:Snowplow.cs

示例15: Initialize

        public override void Initialize()
        {
            base.Initialize();

            graphics = Game1.Instance.Graphics.GraphicsDevice;
            spriteBatch = new SpriteBatch(graphics);
        }
开发者ID:Bigalan09,项目名称:Zombies,代码行数:7,代码来源:SimpleRenderer.cs


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