Пример #1
0
        private RasterizerState(GraphicsDevice device, RasterizerStateDescription rasterizerStateDescription) : base(device)
        {
            Description = rasterizerStateDescription;

#if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            polygonMode = Description.FillMode == FillMode.Solid ? PolygonMode.Fill : PolygonMode.Line;
#endif
            
            // TODO: DepthBiasClamp and various other properties are not fully supported yet
            if (Description.DepthBiasClamp != 0.0f) throw new NotSupportedException();
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XenkoRenderer"/> class.
        /// </summary>
        /// <param name="graphicsDeviceManager">The graphics device manager.</param>
        public XenkoRenderer(GraphicsDeviceManager graphicsDeviceManager, EffectSystem effectSystem)
            : base()
        {
            manager = graphicsDeviceManager;
            this.effectSystem = effectSystem;
            spriteBatch = new SpriteBatch(manager.GraphicsDevice);
            clipRectanges = new Stack<Rectangle>();
            activeEffects = new Stack<EffectInstance>();

            scissorRasterizerStateDescription = RasterizerStates.CullNone;
            scissorRasterizerStateDescription.ScissorTestEnable = true; // enables the scissor test

            geometryRasterizerStateDescription = RasterizerStates.CullNone;
            //geometryRasterizerStateDescription.FillMode = FillMode.Wireframe;
            geometryPipelineState = new MutablePipelineState(manager.GraphicsDevice);
            geometryPipelineState.State.DepthStencilState = DepthStencilStates.None;
        }
Пример #3
0
        protected override async Task LoadContent()
        {
            await base.LoadContent();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("Font");

            wireframeState = new RasterizerStateDescription(CullMode.Back) { FillMode = FillMode.Wireframe };

            materials.Add(Content.Load<Material>("NoTessellation"));
            materials.Add(Content.Load<Material>("FlatTessellation"));
            materials.Add(Content.Load<Material>("PNTessellation"));
            materials.Add(Content.Load<Material>("PNTessellationAE"));
            materials.Add(Content.Load<Material>("FlatTessellationDispl"));
            materials.Add(Content.Load<Material>("FlatTessellationDisplAE"));
            materials.Add(Content.Load<Material>("PNTessellationDisplAE"));

            RenderContext.GetShared(Services).RendererInitialized += RendererInitialized;

            var cube = new Entity("Cube") { new ModelComponent(new ProceduralModelDescriptor(new CubeProceduralModel { Size = new Vector3(80), MaterialInstance = { Material = materials[0] } }).GenerateModel(Services)) };
            var sphere = new Entity("Sphere") { new ModelComponent(new ProceduralModelDescriptor(new SphereProceduralModel { Radius = 50, Tessellation = 5, MaterialInstance = { Material = materials[0] }} ).GenerateModel(Services)) };

            var megalodon = new Entity { new ModelComponent { Model = Content.Load<Model>("megalodon Model") } };
            megalodon.Transform.Position= new Vector3(0, -30f, -10f);

            var knight = new Entity { new ModelComponent { Model = Content.Load<Model>("knight Model") } };
            knight.Transform.RotationEulerXYZ = new Vector3(-MathUtil.Pi / 2, MathUtil.Pi / 4, 0);
            knight.Transform.Position = new Vector3(0, -50f, 20f);
            knight.Transform.Scale= new Vector3(0.6f);

            entities.Add(sphere);
            entities.Add(cube);
            entities.Add(megalodon);
            entities.Add(knight);

            camera = new TestCamera();
            CameraComponent = camera.Camera;
            Script.Add(camera);

            // TODO GRAPHICS REFACTOR
            ChangeModel(0);

            camera.Position = new Vector3(25, 45, 80);
            camera.SetTarget(currentEntity, true);
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RasterizerState"/> class.
 /// </summary>
 /// <param name="graphicsDevice">The graphics device.</param>
 /// <param name="rasterizerStateDescription">The rasterizer state description.</param>
 public static RasterizerState New(GraphicsDevice graphicsDevice, RasterizerStateDescription rasterizerStateDescription)
 {
     RasterizerState rasterizerState;
     lock (graphicsDevice.CachedRasterizerStates)
     {
         if (graphicsDevice.CachedRasterizerStates.TryGetValue(rasterizerStateDescription, out rasterizerState))
         {
             // TODO: Appropriate destroy
             rasterizerState.AddReferenceInternal();
         }
         else
         {
             rasterizerState = new RasterizerState(graphicsDevice, rasterizerStateDescription);
             graphicsDevice.CachedRasterizerStates.Add(rasterizerStateDescription, rasterizerState);
         }
     }
     return rasterizerState;
 }
        internal RasterizerState(RasterizerStateDescription rasterizerStateDescription)
        {
            State.ScissorTestEnable = rasterizerStateDescription.ScissorTestEnable;

            State.DepthClamp = !rasterizerStateDescription.DepthClipEnable;

            State.NeedCulling = rasterizerStateDescription.CullMode != CullMode.None;
            State.CullMode = GetCullMode(rasterizerStateDescription.CullMode);

            State.FrontFaceDirection =
                rasterizerStateDescription.FrontFaceCounterClockwise
                ? FrontFaceDirection.Cw
                : FrontFaceDirection.Ccw;

            State.DepthBias = rasterizerStateDescription.DepthBias;
            State.SlopeScaleDepthBias = rasterizerStateDescription.SlopeScaleDepthBias;

#if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES
            State.PolygonMode = rasterizerStateDescription.FillMode == FillMode.Solid ? PolygonMode.Fill : PolygonMode.Line;
#endif

            // TODO: DepthBiasClamp and various other properties are not fully supported yet
            if (rasterizerStateDescription.DepthBiasClamp != 0.0f) throw new NotSupportedException();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RasterizerState"/> class.
        /// </summary>
        /// <param name="device">The device.</param>
        /// <param name="name">The name.</param>
        /// <param name="rasterizerStateDescription">The rasterizer state description.</param>
        private RasterizerState(GraphicsDevice device, RasterizerStateDescription rasterizerStateDescription) : base(device)
        {
            Description = rasterizerStateDescription;

            CreateNativeDeviceChild();
        }
Пример #7
0
 /// <summary>
 /// Create a new fake rasterizer state for serialization.
 /// </summary>
 /// <param name="description">The description of the rasterizer state</param>
 /// <returns>The fake rasterizer state</returns>
 public static RasterizerState NewFake(RasterizerStateDescription description)
 {
     return new RasterizerState(description);
 }
Пример #8
0
 // For FakeRasterizerState.
 private RasterizerState(RasterizerStateDescription description)
 {
     Description = description;
 }
Пример #9
0
 public RasterizerState(GraphicsDevice graphicsDevice, RasterizerStateDescription rasterizerStateDescription)
 {
     throw new NotImplementedException();
 }
 private PipelineRasterizationStateCreateInfo CreateRasterizationState(RasterizerStateDescription description)
 {
     return new PipelineRasterizationStateCreateInfo
     {
         StructureType = StructureType.PipelineRasterizationStateCreateInfo,
         CullMode = VulkanConvertExtensions.ConvertCullMode(description.CullMode),
         FrontFace = description.FrontFaceCounterClockwise ? FrontFace.CounterClockwise : FrontFace.Clockwise,
         PolygonMode = VulkanConvertExtensions.ConvertFillMode(description.FillMode),
         DepthBiasEnable = true, // TODO VULKAN
         DepthBiasConstantFactor = description.DepthBias,
         DepthBiasSlopeFactor = description.SlopeScaleDepthBias,
         DepthBiasClamp = description.DepthBiasClamp,
         LineWidth = 1.0f,
         DepthClampEnable = !description.DepthClipEnable,
         RasterizerDiscardEnable = false,
     };
 }
Пример #11
0
 public RasterizerState(GraphicsDevice graphicsDevice, RasterizerStateDescription rasterizerStateDescription)
 {
     throw new NotImplementedException();
 }