Example #1
0
        public Rectangle(Renderer renderer, Vector2I screenSize, Vector2I position, Vector2I size, Vector4 color, float depth = 0.0f)
        {
            _shader = renderer.ColorShader;
            Position = position;
            ScreenSize = screenSize;
            Size = size;
            _color = color;
            _changed = true;
            Depth = depth;

            int vertexCount = 4;
            _indexCount = 6;

            _vertices = new VertexDefinition.PositionColor[vertexCount];
            UInt32[] indices = { 0, 1, 2, 0, 3, 1 };

            _vertexBuffer = Buffer.Create(renderer.DirectX.Device, _vertices,
                new BufferDescription
                {
                    Usage = ResourceUsage.Dynamic,
                    SizeInBytes = Utilities.SizeOf<VertexDefinition.PositionColor>() * vertexCount,
                    BindFlags = BindFlags.VertexBuffer,
                    CpuAccessFlags = CpuAccessFlags.Write,
                    OptionFlags = ResourceOptionFlags.None,
                    StructureByteStride = 0
                });

            _indexBuffer = Buffer.Create(renderer.DirectX.Device, BindFlags.IndexBuffer, indices);
        }
Example #2
0
 public Renderer()
 {
     CreateWindow();
     DirectX = new Dx11(Form);
     ScreenSize = new Vector2I(ConfigurationManager.Config.Width, ConfigurationManager.Config.Height);
     Light = new Light
     {
         Direction = new Vector3(1.0f, -1.0f, 0.0f),
         Color = new Vector4(1.0f, 1.0f, 1.0f, 1.0f),
         AmbiantColor = new Vector4(0.16f, 0.16f, 0.16f, 1.0f),
         SpecularPower = 32.0f,
         SpecularColor = new Vector4(1.0f, 1.0f, 0.7f, 1.0f)
     };
     ColorShader = new ColorShader(DirectX.Device);
     TextureShader = new TextureShader(DirectX.Device);
     LightShader = new LightShader(DirectX.Device);
     TranslateShader = new TranslateShader(DirectX.Device);
     CircleShader = new FontShader(DirectX.Device);
     FontShader = new FontShader(DirectX.Device);
     TextManager = new TextManager(DirectX.Device, ConfigurationManager.Config.Width, ConfigurationManager.Config.Height);
     TextureManager = new TextureManager(DirectX.Device);
     _renderables = new List<RenderableGameComponent>();
 }