Esempio n. 1
0
 private RenderTargetObject(LightDevice device)
 {
     _device = device;
     device.AddComponent(this);
     device.ReleaseRenderTargets += ReleaseView;
     device.RebuildRenderTargets += RebuildView;
 }
Esempio n. 2
0
        internal protected AbstractConstantBuffer(LightDevice device, IntPtr buffer)
        {
            _device = device;
            device.AddComponent(this);

            _buffer = buffer;
        }
Esempio n. 3
0
        internal AbstractShaderResourceBuffer(LightDevice device, IntPtr pBuffer, IntPtr pView)
        {
            _device = device;
            device.AddComponent(this);

            _pBuffer = pBuffer;
            _pView   = pView;
        }
Esempio n. 4
0
        //TODO get pipeline object

        internal VertexDataProcessor(LightDevice device, IntPtr layout)
        {
            _device = device;
            device.AddComponent(this);

            _inputLayout  = layout;
            _bufferUpdate = new BufferUpdate(device);
        }
Esempio n. 5
0
        internal IndexBuffer(LightDevice device, IntPtr ptr, int bitWidth, int size)
        {
            _device = device;
            device.AddComponent(this);

            _ptr      = ptr;
            _bitWidth = bitWidth;
            _size     = size;
        }
Esempio n. 6
0
        internal Texture2D(LightDevice device, IntPtr tex, IntPtr view, int w, int h, bool holdPtr = true)
        {
            _device = device;
            device.AddComponent(this);

            _holdPointer = holdPtr;

            _texture = tex;
            _view    = view;

            Width  = w;
            Height = h;
        }
Esempio n. 7
0
        internal VertexBuffer(LightDevice device, IBufferUpdate update, IntPtr buffer, IntPtr layout,
                              int stride, int vertexCount, bool isDynamic)
        {
            _device = device;
            device.AddComponent(this);

            _update      = update;
            _buffer      = buffer;
            _layout      = layout;
            _stride      = (uint)stride;
            _vertexCount = vertexCount;
            _isDynamic   = isDynamic;
        }
Esempio n. 8
0
        internal Pipeline(LightDevice device, IntPtr v, IntPtr g, IntPtr p, IntPtr sign, InputTopology topology)
        {
            _device = device;
            device.AddComponent(this);
            _device.ResolutionChanged += DeviceBufferResized;

            _vertex        = v;
            _geometry      = g;
            _pixel         = p;
            _signatureBlob = sign;

            _viewport = new Viewport
            {
                Width    = _device.ScreenWidth,
                Height   = _device.ScreenHeight,
                MaxDepth = 1.0f,
            };
            _topology = topology;
        }
Esempio n. 9
0
        public AbstractFontCache(LightDevice device, Font font, PixelFormat format, Color foreground, Color background)
        {
            _device = device;
            device.AddComponent(this);

            Font            = font;
            PixelFormat     = format;
            BackgroundColor = background;
            ForegroundColor = foreground;
            _brush          = new SolidBrush(foreground);
            var height = (int)Math.Ceiling(font.GetHeight());
            int bitmapSize;

            if (height < 85)
            {
                bitmapSize = 256;
            }
            else
            {
                bitmapSize = Round2Power(height * 3);
            }
            BufferWidth        = bitmapSize;
            BufferHeight       = bitmapSize;
            _gdiBitmap         = new Bitmap(BufferWidth, BufferHeight, format);
            _gdiBitmapGraphics = Graphics.FromImage(_gdiBitmap);
            _gdiBitmapGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;

            _formatSingle = new StringFormat();
            _formatSingle.SetMeasurableCharacterRanges(new[] { new CharacterRange(0, 1) });
            _formatDouble = new StringFormat();
            _formatDouble.SetMeasurableCharacterRanges(new[] { new CharacterRange(0, 2) });
            _empty = new CachedRegion
            {
                Bitmap = null,
                X      = 0,
                Y      = 0,
                Width  = 0,
                Height = 0,
            };
        }
Esempio n. 10
0
        public Sprite(LightDevice device)
        {
            _device = device;
            device.AddComponent(this);

            _pipeline = device.CompilePipeline(InputTopology.Triangle,
                                               ShaderSource.FromString(PipelineCode, ShaderType.Vertex | ShaderType.Pixel));
            _pipeline.SetBlender(Blender.AlphaBlender);

            _vertexProcessor = _pipeline.CreateVertexDataProcessor <Vertex>();
            _array           = new[] {
                new Vertex {
                    TexCoord = new Vector4(0, 0, 0, 0), Position = new Vector4(0, 0, 0, 0)
                },
                new Vertex {
                    TexCoord = new Vector4(1, 0, 0, 0), Position = new Vector4(1, 0, 0, 0)
                },
                new Vertex {
                    TexCoord = new Vector4(0, 1, 0, 0), Position = new Vector4(0, 1, 0, 0)
                },

                new Vertex {
                    TexCoord = new Vector4(0, 1, 0, 0), Position = new Vector4(0, 1, 0, 0)
                },
                new Vertex {
                    TexCoord = new Vector4(1, 0, 0, 0), Position = new Vector4(1, 0, 0, 0)
                },
                new Vertex {
                    TexCoord = new Vector4(1, 1, 0, 0), Position = new Vector4(1, 1, 0, 0)
                },
            };
            _buffer = _vertexProcessor.CreateDynamicBuffer(6);

            _constant = _pipeline.CreateConstantBuffer <VSConstant>();
            _pipeline.SetConstant(ShaderType.Vertex, 0, _constant);
        }