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


C# Graphics.GraphicsDevice类代码示例

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


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

示例1: SwapChainGraphicsPresenter

 public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
 {
     gameWindow = (iPhoneOSGameView)Description.DeviceWindowHandle.NativeHandle;
     device.InitDefaultRenderTarget(presentationParameters);
     backBuffer = device.DefaultRenderTarget;
     DepthStencilBuffer = device.windowProvidedDepthTexture;
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:7,代码来源:SwapChainGraphicsPresenter.iOS.cs

示例2: DepthStencilState

        /// <summary>
        /// Initializes a new instance of the <see cref="DepthStencilState"/> class.
        /// </summary>
        /// <param name="depthEnable">if set to <c>true</c> [depth enable].</param>
        /// <param name="depthWriteEnable">if set to <c>true</c> [depth write enable].</param>
        /// <param name="name">The name.</param>
        private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription)
            : base(device)
        {
            Description = depthStencilStateDescription;

            CreateNativeDeviceChild();
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:13,代码来源:DepthStencilState.Direct3D.cs

示例3: FromFileData

        /// <summary>
        /// Creates a texture from an image file data (png, dds, ...).
        /// </summary>
        /// <param name="graphicsDevice">The graphics device in which to create the texture</param>
        /// <param name="data">The image file data</param>
        /// <returns>The texture</returns>
        public static Texture FromFileData(GraphicsDevice graphicsDevice, byte[] data)
        {
            Texture result;

            var loadAsSRgb = graphicsDevice.ColorSpace == ColorSpace.Linear;

            using (var imageStream = new MemoryStream(data))
            {
                using (var image = Image.Load(imageStream, loadAsSRgb))
                {
                    result = Texture.New(graphicsDevice, image);
                }
            }

            result.Reload = graphicsResource =>
            {
                using (var imageStream = new MemoryStream(data))
                {
                    using (var image = Image.Load(imageStream, loadAsSRgb))
                    {
                        ((Texture)graphicsResource).Recreate(image.ToDataBox());
                    }
                }
            };

            return result;
        }
开发者ID:RainsSoft,项目名称:paradox,代码行数:33,代码来源:Texture.Extensions.cs

示例4: DepthStencilBuffer

        internal DepthStencilBuffer(GraphicsDevice device, Texture2D depthTexture, bool isReadOnly) : base(device)
        {
            DescriptionInternal = depthTexture.Description;
            depthTexture.AddReferenceInternal();
            Texture = depthTexture;

            resourceId = Texture.ResourceId;

            if (Description.Format == PixelFormat.D24_UNorm_S8_UInt ||
                Description.Format == PixelFormat.D32_Float_S8X24_UInt)
            {
                IsDepthBuffer = true;
                IsStencilBuffer = true;
            }
            else if (Description.Format == PixelFormat.D32_Float || 
                     Description.Format == PixelFormat.D16_UNorm)
            {
                IsDepthBuffer = true;
                IsStencilBuffer = false;
            }
            else 
                throw new NotSupportedException("The provided depth stencil format is currently not supported"); // implement composition for other formats


#if !SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            if (isReadOnly)
            {
                if (device.versionMajor < 4)
                {
                    needReadOnlySynchronization = true;
                    throw new NotImplementedException();
                }
            }
#endif
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:35,代码来源:DepthStencilBuffer.OpenGL.cs

示例5: Shader

        private Shader(GraphicsDevice device, ShaderStage shaderStage, byte[] shaderStageBytecode)
            : base(device)
        {
            this.stage = shaderStage;

            var shaderStageGl = ConvertShaderStage(shaderStage);

            // Decode shader StageBytecode
            var binarySerializationReader = new BinarySerializationReader(new MemoryStream(shaderStageBytecode));
            var shaderBytecodeData = new OpenGLShaderBytecodeData();
            shaderBytecodeData.Serialize(binarySerializationReader, ArchiveMode.Deserialize);

            using (GraphicsDevice.UseOpenGLCreationContext())
            {
                resourceId = GL.CreateShader(shaderStageGl);

                if (shaderBytecodeData.IsBinary)
                {
                    GL.ShaderBinary(1, ref resourceId, (BinaryFormat)shaderBytecodeData.BinaryFormat, shaderBytecodeData.Binary, shaderBytecodeData.Binary.Length);
                }
                else
                {
                    GL.ShaderSource(resourceId, shaderBytecodeData.Source);
                    GL.CompileShader(resourceId);

                    var log = GL.GetShaderInfoLog(resourceId);

                    int compileStatus;
                    GL.GetShader(resourceId, ShaderParameter.CompileStatus, out compileStatus);

                    if (compileStatus != 1)
                        throw new InvalidOperationException(string.Format("Error while compiling GLSL shader: {0}", log));
                }
            }
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:35,代码来源:Shader.OpenGL.cs

示例6: SwapChainGraphicsPresenter

        public SwapChainGraphicsPresenter(GraphicsDevice device, PresentationParameters presentationParameters) : base(device, presentationParameters)
        {
            gameWindow = (iPhoneOSGameView)Description.DeviceWindowHandle.NativeHandle;
            device.InitDefaultRenderTarget(presentationParameters);

            backBuffer = Texture.New2D(device, Description.BackBufferWidth, Description.BackBufferHeight, presentationParameters.BackBufferFormat, TextureFlags.RenderTarget | TextureFlags.ShaderResource);
        }
开发者ID:ItayGal2,项目名称:paradox,代码行数:7,代码来源:SwapChainGraphicsPresenter.iOS.cs

示例7: DepthStencilState

        private DepthStencilState(GraphicsDevice device, DepthStencilStateDescription depthStencilStateDescription)
            : base(device)
        {
            Description = depthStencilStateDescription;

            depthFunction = Description.DepthBufferFunction.ToOpenGLDepthFunction();
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:7,代码来源:DepthStencilState.OpenGL.cs

示例8: Shader

        private Shader(GraphicsDevice device, ShaderStage shaderStage, byte[] shaderBytecode)
            : base(device)
        {
            this.stage = shaderStage;

            switch (shaderStage)
            {
                case ShaderStage.Vertex:
                    NativeDeviceChild = new VertexShader(device.NativeDevice, shaderBytecode);
                    NativeInputSignature = shaderBytecode;
                    break;
                case ShaderStage.Hull:
                    NativeDeviceChild = new HullShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Domain:
                    NativeDeviceChild = new DomainShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Geometry:
                    NativeDeviceChild = new GeometryShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Pixel:
                    NativeDeviceChild = new PixelShader(device.NativeDevice, shaderBytecode);
                    break;
                case ShaderStage.Compute:
                    NativeDeviceChild = new ComputeShader(device.NativeDevice, shaderBytecode);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("shaderStage");
            }
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:30,代码来源:Shader.Direct3D.cs

示例9: CreateDebugPrimitive

        public override MeshDraw CreateDebugPrimitive(GraphicsDevice device)
        {
            if (cachedDebugPrimitive != null) return cachedDebugPrimitive;

            var verts = new VertexPositionNormalTexture[pointsList.Count];
            for (var i = 0; i < pointsList.Count; i++)
            {
                verts[i].Position = pointsList[i];
                verts[i].TextureCoordinate = Vector2.Zero;
                verts[i].Normal = Vector3.Zero;
            }

            var intIndices = indicesList.Select(x => (int)x).ToArray();

            ////calculate basic normals
            ////todo verify, winding order might be wrong?
            for (var i = 0; i < indicesList.Count; i += 3)
            {
                var i1 = intIndices[i];
                var i2 = intIndices[i + 1];
                var i3 = intIndices[i + 2];
                var a = verts[i1];
                var b = verts[i2];
                var c = verts[i3];
                var n = Vector3.Cross((b.Position - a.Position), (c.Position - a.Position));
                n.Normalize();
                verts[i1].Normal = verts[i2].Normal = verts[i3].Normal = n;
            }

            var meshData = new GeometricMeshData<VertexPositionNormalTexture>(verts, intIndices, false);

            cachedDebugPrimitive = new GeometricPrimitive(device, meshData).ToMeshDraw();

            return cachedDebugPrimitive;
        }
开发者ID:releed,项目名称:paradox,代码行数:35,代码来源:ConvexHullColliderShape.cs

示例10: BlendStateFactory

        /// <summary>
        /// Initializes a new instance of the <see cref="BlendStateFactory"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        internal BlendStateFactory(GraphicsDevice device)
        {
            var blendDescription = new BlendStateDescription(Blend.One, Blend.Zero);
            blendDescription.SetDefaults();
            Default = BlendState.New(device, blendDescription).DisposeBy(device);
            Default.Name = "Default";

            Additive = BlendState.New(device, new BlendStateDescription(Blend.SourceAlpha, Blend.One)).DisposeBy(device);
            Additive.Name = "Additive";

            AlphaBlend = BlendState.New(device, new BlendStateDescription(Blend.One, Blend.InverseSourceAlpha)).DisposeBy(device);
            AlphaBlend.Name = "AlphaBlend";

            NonPremultiplied = BlendState.New(device, new BlendStateDescription(Blend.SourceAlpha, Blend.InverseSourceAlpha)).DisposeBy(device);
            NonPremultiplied.Name = "NonPremultiplied";

            Opaque = BlendState.New(device, new BlendStateDescription(Blend.One, Blend.Zero)).DisposeBy(device);
            Opaque.Name = "Opaque";

            var colorDisabledDescription = new BlendStateDescription();
            colorDisabledDescription.SetDefaults();
            colorDisabledDescription.RenderTargets[0].ColorWriteChannels = ColorWriteChannels.None;
            ColorDisabled = BlendState.New(device, colorDisabledDescription).DisposeBy(device);
            ColorDisabled.Name = "ColorDisabled";
        }
开发者ID:releed,项目名称:paradox,代码行数:29,代码来源:BlendStateFactory.cs

示例11: GraphicsDeviceFeatures

        internal GraphicsDeviceFeatures(GraphicsDevice deviceRoot)
        {
            mapFeaturesPerFormat = new FeaturesPerFormat[256];

            IsProfiled = false;

            using (deviceRoot.UseOpenGLCreationContext())
            {
                Vendor = GL.GetString(StringName.Vendor);
                Renderer = GL.GetString(StringName.Renderer);
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
                SupportedExtensions = GL.GetString(StringName.Extensions).Split(' ');
#else
                int numExtensions;
                GL.GetInteger(GetPName.NumExtensions, out numExtensions);
                SupportedExtensions = new string[numExtensions];
                for (int extensionIndex = 0; extensionIndex < numExtensions; ++extensionIndex)
                {
                    SupportedExtensions[extensionIndex] = GL.GetString(StringName.Extensions, extensionIndex);
                }
#endif
            }

#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            var isOpenGLES3 = deviceRoot.versionMajor >= 3;

            deviceRoot.HasDepth24 = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_depth24");
            deviceRoot.HasPackedDepthStencilExtension = SupportedExtensions.Contains("GL_OES_packed_depth_stencil");
            deviceRoot.HasExtTextureFormatBGRA8888 = SupportedExtensions.Contains("GL_EXT_texture_format_BGRA8888")
                                       || SupportedExtensions.Contains("GL_APPLE_texture_format_BGRA8888");
            deviceRoot.HasRenderTargetFloat = SupportedExtensions.Contains("GL_EXT_color_buffer_float");
            deviceRoot.HasRenderTargetHalf = SupportedExtensions.Contains("GL_EXT_color_buffer_half_float");
            deviceRoot.HasVAO = isOpenGLES3 || SupportedExtensions.Contains("GL_OES_vertex_array_object");

            // Compute shaders available in OpenGL ES 3.1
            HasComputeShaders = isOpenGLES3 && deviceRoot.versionMinor >= 1;
            HasDoublePrecision = false;
            
            // TODO: from 3.1: draw indirect, separate shader object
            // TODO: check tessellation & geometry shaders: GL_ANDROID_extension_pack_es31a
#else
            deviceRoot.HasVAO = true;

            // Compute shaders available in OpenGL 4.3
            HasComputeShaders = deviceRoot.versionMajor >= 4 && deviceRoot.versionMinor >= 3;
            HasDoublePrecision = SupportedExtensions.Contains("GL_ARB_vertex_attrib_64bit");

            // TODO: from 4.0: tessellation, draw indirect
            // TODO: from 4.1: separate shader object
#endif
            
            HasDriverCommandLists = false;
            HasMultiThreadingConcurrentResources = false;

            // TODO: Enum supported formats in mapFeaturesPerFormat

            // Find shader model based on OpenGL version (might need to check extensions more carefully)
            Profile = OpenGLUtils.GetFeatureLevel(deviceRoot.versionMajor, deviceRoot.versionMinor);
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:59,代码来源:GraphicsDeviceFeatures.OpenGL.cs

示例12: Texture3D

        protected internal Texture3D(GraphicsDevice device, Texture3D texture) : base(device, texture, ViewType.Full, 0, 0)
        {
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            throw new NotImplementedException();
#else
            Target = TextureTarget.Texture3D;
#endif
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:8,代码来源:Texture3D.OpenGL.cs

示例13: Buffer

 /// <summary>
 /// Initializes a new instance of the <see cref="Buffer" /> class.
 /// </summary>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="description">The description.</param>
 /// <param name="bufferFlags">Type of the buffer.</param>
 /// <param name="viewFormat">The view format.</param>
 /// <param name="dataPointer">The data pointer.</param>
 protected Buffer(GraphicsDevice device, BufferDescription description, BufferFlags bufferFlags, PixelFormat viewFormat, IntPtr dataPointer) : base(device)
 {
     Description = description;
     BufferFlags = bufferFlags;
     ViewFormat = viewFormat;
     //InitCountAndViewFormat(out this.elementCount, ref ViewFormat);
     //Initialize(device.RootDevice, null);
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:16,代码来源:Buffer.Null.cs

示例14: PhysicsDebugEffect

 public PhysicsDebugEffect(GraphicsDevice graphicsDevice)
     : base(graphicsDevice, bytecode ?? (bytecode = EffectBytecode.FromBytesSafe(binaryBytecode)))
 {
     parameters = new ParameterCollection();
     Color = new Color4(1.0f);
     WorldViewProj = Matrix.Identity;
     UseUv = true;
 }
开发者ID:Powerino73,项目名称:paradox,代码行数:8,代码来源:PhysicsDebugEffect.cs

示例15: VertexArrayObject

        private VertexArrayObject(GraphicsDevice graphicsDevice, EffectInputSignature shaderSignature, IndexBufferBinding indexBufferBinding, VertexBufferBinding[] vertexBufferBindings)
            : base(graphicsDevice)
        {
            this.vertexBufferBindings = vertexBufferBindings;
            this.indexBufferBinding = indexBufferBinding;
            this.preferredInputSignature = shaderSignature;

            CreateAttributes();
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:9,代码来源:VertexArrayObject.OpenGL.cs


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