コード例 #1
0
        public UIRenderer(Spritebatch2D texture)
        {
            Texture = texture;

            Window.Changed += () => {
                matrix = new Matrix(Window.ProjectionSize, MIN_DEPTH, MAX_DEPTH);
            };
            matrix = new Matrix(Window.ProjectionSize, MIN_DEPTH, MAX_DEPTH);

            preVertexBuffer  = new CachedGPUBuffer(3, MAX_QUADS_PER_BUFFER, PrimitiveType.Quad);
            preTextureBuffer = new CachedGPUBuffer(2, MAX_QUADS_PER_BUFFER, PrimitiveType.Quad);
            preColorBuffer   = new CachedGPUBuffer(4, MAX_QUADS_PER_BUFFER, PrimitiveType.Quad);

            postVertexBuffer  = new CachedGPUBuffer(3, MAX_QUADS_PER_BUFFER, PrimitiveType.Quad);
            postTextureBuffer = new CachedGPUBuffer(2, MAX_QUADS_PER_BUFFER, PrimitiveType.Quad);
            postColorBuffer   = new CachedGPUBuffer(4, MAX_QUADS_PER_BUFFER, PrimitiveType.Quad);

            IndexBuffer sharedIndexBuffer = new IndexBuffer(MAX_QUADS_PER_BUFFER);

            preBuffer  = new BufferBatch(sharedIndexBuffer, preVertexBuffer, preColorBuffer, preTextureBuffer);
            postBuffer = new BufferBatch(sharedIndexBuffer, postVertexBuffer, postColorBuffer, postTextureBuffer);

            preBufferLength   = postBufferLength = 0;
            preRenderCount    = postRenderCount = 0;
            preBufferChanged  = postBufferChanged = false;
            preBufferEntries  = new Dictionary <Element, BufferEntry>( );
            postBufferEntries = new Dictionary <Element, BufferEntry>( );

            updateQueue = new Queue <Element>( );
        }
コード例 #2
0
ファイル: UIRenderer.cs プロジェクト: tipfom/quasi_
        public static void Init()
        {
            startPositions = new int[] { 0, 0, 0 };
            renderCount    = 0;
            vertexCount    = 0;
            updateQueue    = new Queue <UIItem>();

            IndexBuffer sharedIndexBuffer = new IndexBuffer(MAX_QUADS);

            vertexBuffer  = new CachedGPUBuffer(2, MAX_QUADS, BufferPrimitiveType.Quad);
            textureBuffer = new CachedGPUBuffer(2, MAX_QUADS, BufferPrimitiveType.Quad);
            colorBuffer   = new CachedGPUBuffer(4, MAX_QUADS, BufferPrimitiveType.Quad);
            buffer        = new BufferBatch(sharedIndexBuffer, vertexBuffer, colorBuffer, textureBuffer);

            uiItems       = new Dictionary <Layer, List <UIItem> >();
            uiItemsOffset = new Dictionary <Layer, int>();
            indexUsage    = new List <Tuple <UIItem, int> >[] { new List <Tuple <UIItem, int> >(), new List <Tuple <UIItem, int> >(), new List <Tuple <UIItem, int> >() };
        }
コード例 #3
0
        private void Window_Changed()
        {
            matrix.UpdateProjection(Window.ProjectionSize);
            matrix.CalculateMVP();

            if (2 * Window.Ratio / DRAW_WIDTH != VertexSize)
            {
                VertexSize    = 2 * Window.Ratio / DRAW_WIDTH;
                DrawSize      = new Size(DRAW_WIDTH + 2, Mathi.Ceil(DRAW_WIDTH / Window.Ratio + 1));
                drawThreshold = new Vector2(DrawSize.Width / 2f, DrawSize.Height / 2f);

                mainBuffer?.Dispose();
                mainTextureBuffer = new CachedGPUBuffer(2, DrawSize.Area * 2, BufferPrimitiveType.Quad);
                mainBuffer        = new BufferBatch(new IndexBuffer(DrawSize.Area * 2), new GPUBuffer(2, DrawSize.Area * 2, BufferPrimitiveType.Quad, GenerateMainVerticies()), mainTextureBuffer);

                foregroundBuffer?.Dispose();
                foregroundTextureBuffer = new CachedGPUBuffer(2, DrawSize.Area, BufferPrimitiveType.Quad);
                foregroundBuffer        = new BufferBatch(new IndexBuffer(DrawSize.Area), new GPUBuffer(2, DrawSize.Area, BufferPrimitiveType.Quad, GenerateForegroundVerticies()), foregroundTextureBuffer);

                UpdateTextureBuffer();
            }
        }