Exemplo n.º 1
0
        /// <summary>
        /// Function to initialize the texture with optional initial data.
        /// </summary>
        /// <param name="initialData">Data used to populate the image.</param>
        protected override void OnInitialize(GorgonImageData initialData)
        {
            if ((Settings.Format != BufferFormat.Unknown) && (Settings.TextureFormat == BufferFormat.Unknown))
            {
                Settings.TextureFormat = Settings.Format;
            }

            var desc = new D3D.Texture1DDescription
            {
                ArraySize      = Settings.ArrayCount,
                Format         = (Format)Settings.TextureFormat,
                Width          = Settings.Width,
                MipLevels      = Settings.MipCount,
                BindFlags      = GetBindFlags(false, true),
                Usage          = D3D.ResourceUsage.Default,
                CpuAccessFlags = D3D.CpuAccessFlags.None,
                OptionFlags    = D3D.ResourceOptionFlags.None
            };

            Gorgon.Log.Print("{0} {1}: Creating 1D render target texture...", LoggingLevel.Verbose, GetType().Name, Name);

            // Create the texture.
            D3DResource = initialData != null
                                                          ? new D3D.Texture1D(Graphics.D3DDevice, desc, initialData.Buffers.DataBoxes)
                              : new D3D.Texture1D(Graphics.D3DDevice, desc);

            // Create the default render target view.
            _defaultRenderTargetView = GetRenderTargetView(Settings.Format, 0, 0, 1);

            GorgonRenderStatistics.RenderTargetCount++;
            GorgonRenderStatistics.RenderTargetSize += SizeInBytes;

            CreateDepthStencilBuffer();

            // Set default viewport.
            Viewport = new GorgonViewport(0, 0, Settings.Width, 1.0f, 0.0f, 1.0f);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Function to create a new 2D renderer interface.
 /// </summary>
 /// <param name="graphics">Graphics interface used to create the 2D interface.</param>
 /// <param name="target">Default target for the renderer.</param>
 /// <param name="vertexCacheSize">[Optional] The number of vertices that the renderer will cache when drawing.</param>
 /// <returns>A new 2D graphics interface.</returns>
 /// <remarks>This will create a 2D rendering interface with a previously existing render target as its default target.
 /// <para>The <paramref name="vertexCacheSize"/> allows for adjustment to the size of the cache that stores vertices when rendering.  More vertices means a larger buffer and more memory used, but may
 /// provide a performance increase by rendering many objects at the same time.  Lower values means a smaller buffer and possibly reduced performance because not as many objects can be drawn
 /// at a given time.  Any performance increase from this value depends upon multiple factors such as available RAM, video driver, video card, etc...</para>
 /// </remarks>
 /// <exception cref="System.ArgumentNullException">Thrown when the <paramref name="target"/> parameter is NULL (Nothing in VB.Net).</exception>
 public static Gorgon2D Create2DRenderer(this GorgonOutputMerger graphics, GorgonRenderTargetView target, int vertexCacheSize = 32768)
 {
     return(Create2DRenderer(target, false, vertexCacheSize));
 }