Esempio n. 1
0
        public void Render(System.Windows.Media.DrawingContext drawingContext, Size renderSize, TileRenderContext ctx)
        {
            if (m_disposed)
                return;

            var renderWidth = (int)Math.Ceiling(renderSize.Width);
            var renderHeight = (int)Math.Ceiling(renderSize.Height);

            m_interopImageSource.Lock();

            if (m_interopImageSource.PixelWidth != renderWidth || m_interopImageSource.PixelHeight != renderHeight)
            {
                InitTextureRenderSurface(renderWidth, renderHeight);
                // force a full update if we re-allocate the render surface
                ctx.TileDataInvalid = true;
                ctx.TileRenderInvalid = true;
            }

            if (ctx.TileDataInvalid)
                m_scene.SendMapData(this.RenderData, ctx.RenderGridSize.Width, ctx.RenderGridSize.Height);

            if (ctx.TileRenderInvalid)
            {
                m_scene.Render((float)ctx.TileSize, ctx.RenderOffset);
                m_device.ImmediateContext.Flush();
            }

            m_interopImageSource.InvalidateD3DImage();

            m_interopImageSource.Unlock();

            drawingContext.DrawImage(m_interopImageSource, new Rect(renderSize));
        }
Esempio n. 2
0
        public void Render(DrawingContext dc, Size renderSize, TileRenderContext ctx)
        {
            dc.DrawRectangle(Brushes.Black, null, new Rect(0, 0, renderSize.Width, renderSize.Height));

            dc.PushTransform(new TranslateTransform(ctx.RenderOffset.X, ctx.RenderOffset.Y));
            dc.PushTransform(new ScaleTransform(ctx.TileSize, ctx.TileSize));

            for (int y = 0; y < ctx.RenderGridSize.Height && y < m_renderData.Height; ++y)
            {
                for (int x = 0; x < ctx.RenderGridSize.Width && x < m_renderData.Width; ++x)
                {
                    dc.PushTransform(new TranslateTransform(x, y));
                    RenderTile(dc, x, y);
                    dc.Pop();
                }
            }

            dc.Pop();
            dc.Pop();
        }
Esempio n. 3
0
 protected abstract void OnRenderTiles(DrawingContext drawingContext, Size renderSize, TileRenderContext ctx);
Esempio n. 4
0
        protected override void OnRenderTiles(DrawingContext drawingContext, Size renderSize, TileRenderContext ctx)
        {
            if (ctx.TileDataInvalid)
            {
                var width = m_renderData.Width;
                var height = m_renderData.Height;
                var grid = m_renderData.Grid;

                for (int y = 0; y < height; ++y)
                {
                    for (int x = 0; x < width; ++x)
                    {
                        var ml = ScreenTileToMapLocation(new IntVector2(x, y));

                        UpdateTile(ref grid[y, x], ml);
                    }
                }
            }

            m_renderer.Render(drawingContext, renderSize, ctx);
        }
Esempio n. 5
0
 protected abstract void OnRenderTiles(DrawingContext drawingContext, Size renderSize, TileRenderContext ctx);