Ejemplo n.º 1
0
        /// <summary>
        /// Function to create and initialize the various state objects.
        /// </summary>
        private void CreateStates()
        {
            // Create interfaces.
            Rasterizer = new GorgonRasterizerRenderState(this);
            Input      = new GorgonInputGeometry(this);
            Shaders    = new GorgonShaderBinding(this);
            Output     = new GorgonOutputMerger(this);
            Textures   = new GorgonTextures(this);
            Fonts      = new GorgonFonts(this);
            Buffers    = new GorgonBuffers(this);

            ClearState();
        }
Ejemplo 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="window">Window to use for rendering.</param>
        /// <returns>A new 2D graphics interface.</returns>
        /// <remarks>This method creates an internal swap chain and uses that for the display.  To have more control over the initial render target, use the <see cref="Create2DRenderer(GorgonLibrary.Graphics.GorgonOutputMerger,GorgonLibrary.Graphics.GorgonRenderTargetView,int)">Create2DRenderer(GorgonRenderTarget)</see> extension overload.</remarks>
        /// <exception cref="System.ArgumentException">Thrown when the target was not created by the same graphics interface as the one creating the 2D interface.
        /// <para>Thrown when the <paramref name="window"/> parameter is NULL (Nothing in VB.Net), and the <see cref="P:GorgonLibrary.Gorgon.ApplicationForm">Gorgon application window</see> is NULL.</para>
        /// </exception>
        /// <exception cref="GorgonLibrary.GorgonException">Thrown when the video output could not be determined from the window.
        /// <para>-or-</para>
        /// <para>Thrown when the swap chain is going to full screen mode and another swap chain is already on the video output.</para>
        /// </exception>
        public static Gorgon2D Create2DRenderer(this GorgonOutputMerger graphics, Control window)
        {
            if (window != null)
            {
                return(Create2DRenderer(graphics, window, window.ClientSize.Width, window.ClientSize.Height));
            }

            window = Gorgon.ApplicationForm;

            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            return(Create2DRenderer(graphics, window, window.ClientSize.Width, window.ClientSize.Height));
        }
Ejemplo n.º 3
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="window">Window to use for rendering.</param>
        /// <param name="width">Width of the video mode used for rendering.</param>
        /// <param name="height">Height of the video mode used for rendering.</param>
        /// <param name="format">[Optional] Format of the video mode used for rendering.</param>
        /// <param name="isWindowed">[Optional] TRUE to use windowed mode, FALSE to to use full screen mode.</param>
        /// <param name="depthStencilFormat">[Optional] Depth/stencil buffer format.</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 method creates an internal swap chain and uses that for the display.  To have more control over the initial render target, use the <see cref="Create2DRenderer(GorgonLibrary.Graphics.GorgonOutputMerger,GorgonLibrary.Graphics.GorgonRenderTargetView,int)">Create2DRenderer(GorgonRenderTarget)</see> extension overload.
        /// <para>The depth/stencil buffer is optional, and will only be used when <paramref name="depthStencilFormat"/> is not set to Unknown.</para>
        /// <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.ArgumentException">Thrown when the target was not created by the same graphics interface as the one creating the 2D interface.
        /// <para>Thrown when the <paramref name="window"/> parameter is NULL (Nothing in VB.Net), and the <see cref="P:GorgonLibrary.Gorgon.ApplicationForm">Gorgon application window</see> is NULL.</para>
        /// <para>-or-</para>
        /// <para>Thrown when the <paramref name="format"/> parameter cannot be used by the video device for displaying data or for the depth/stencil buffer.</para>
        /// </exception>
        /// <exception cref="GorgonLibrary.GorgonException">Thrown when the video output could not be determined from the window.
        /// <para>-or-</para>
        /// <para>Thrown when the swap chain is going to full screen mode and another swap chain is already on the video output.</para>
        /// </exception>
        public static Gorgon2D Create2DRenderer(this GorgonOutputMerger graphics, Control window, int width, int height, BufferFormat format = BufferFormat.Unknown, bool isWindowed = true, BufferFormat depthStencilFormat = BufferFormat.Unknown, int vertexCacheSize = 32768)
        {
            GorgonSwapChain swapChain = graphics.CreateSwapChain("Gorgon2D.DefaultSwapChain", new GorgonSwapChainSettings
            {
                BufferCount        = 2,
                DepthStencilFormat = depthStencilFormat,
                Flags         = SwapChainUsageFlags.RenderTarget,
                Format        = format,
                Height        = height,
                IsWindowed    = isWindowed,
                Multisampling = new GorgonMultisampling(1, 0),
                SwapEffect    = SwapEffect.Discard,
                Width         = width,
                Window        = window
            });

            return(Create2DRenderer(swapChain, true, vertexCacheSize));
        }
Ejemplo n.º 4
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));
 }