Exemplo n.º 1
0
        public override bool CreateGeometry(RenderContext11 renderContext, bool uiThread)
        {
            if (texture == null || (Volitile && !ReadyToRender))
            {
                GetParameters();
                if (ImageData != null)
                {
                    try
                    {
                        MemoryStream ms = new MemoryStream(ImageData);

                        Texture11 old = this.texture;

                        texture = Texture11.FromStream(RenderContext11.PrepDevice, ms);

                        ReadyToRender = true;
                        if (old != null)
                        {
                            old.Dispose();
                            GC.SuppressFinalize(old);
                        }

                        if (Width == 0 && Height == 0)
                        {
                            Width  = texture.Width;
                            Height = texture.Height;
                            if (dataset.WcsImage != null)
                            {
                                if (dataset.WcsImage.SizeX != 0)
                                {
                                    Width = dataset.WcsImage.SizeX;
                                }
                                if (dataset.WcsImage.SizeY != 0)
                                {
                                    Height = dataset.WcsImage.SizeY;
                                }
                            }
                        }
                        ms.Dispose();
                        ImageData = null;
                    }
                    catch
                    {
                        return(false);
                    }
                }

                if (TextureReady)
                {
                    if (dataset.WcsImage != null)
                    {
                        if (dataset.WcsImage is FitsImage)
                        {
                            SetTexture(dataset.WcsImage.GetBitmap());
                            ReadyToRender = true;
                        }
                    }
                }
                if (this.texture == null)
                {
                    if (dataset.WcsImage != null)
                    {
                        if (dataset.WcsImage is FitsImage)
                        {
                            SetTexture(dataset.WcsImage.GetBitmap());
                            ReadyToRender = true;
                        }
                    }

                    if (TextureReady)
                    {
                        paintColor = Color.White;
                        if (dataset.WcsImage != null)
                        {
                            paintColor = dataset.WcsImage.Color;
                            blend      = !dataset.WcsImage.ColorCombine;
                        }


                        if (string.IsNullOrEmpty(FileName))
                        {
                            texture       = Texture11.FromBitmap(RenderContext11.PrepDevice, Image);
                            ReadyToRender = true;
                        }
                        else
                        {
                            try
                            {
                                texture       = Texture11.FromFile(RenderContext11.PrepDevice, FileName);
                                ReadyToRender = true;


                                ReadyToRender = true;
                                if (Width == 0 && Height == 0)
                                {
                                    Width  = texture.Width;
                                    Height = texture.Height;
                                    if (dataset.WcsImage != null)
                                    {
                                        if (dataset.WcsImage.SizeX != 0)
                                        {
                                            Width = dataset.WcsImage.SizeX;
                                        }
                                        if (dataset.WcsImage.SizeY != 0)
                                        {
                                            Height = dataset.WcsImage.SizeY;
                                        }
                                    }
                                }
                            }
                            catch
                            {
                                try
                                {
                                    //texture = Texture.FromBitmap(prepDevice, bmp, Usage.AutoGenerateMipMap, Tile.PoolToUse);

                                    texture       = Texture11.FromFile(RenderContext11.PrepDevice, FileName);
                                    ReadyToRender = true;
                                    Width         = texture.Width;
                                    Height        = texture.Height;
                                    if (dataset.WcsImage.SizeX != 0)
                                    {
                                        Width = dataset.WcsImage.SizeX;
                                    }
                                    if (dataset.WcsImage.SizeY != 0)
                                    {
                                        Height = dataset.WcsImage.SizeY;
                                    }
                                }
                                catch
                                {
                                    errored = true;
                                }
                            }
                        }
                    }
                }
            }

            if (vertexBuffer == null)
            {
                GetParameters();
                vertexBuffer = new VertexBuffer11(typeof(PositionNormalTexturedX2), 4, RenderContext11.PrepDevice);
                indexBuffer  = new IndexBuffer11(typeof(short), 6, RenderContext11.PrepDevice);
                this.OnCreateVertexBuffer(vertexBuffer);
            }



            return(true);
        }
Exemplo n.º 2
0
 public static Texture11 GetTexture(Stream stream)
 {
     return(Texture11.FromStream(RenderContext11.PrepDevice, stream));
 }