Esempio n. 1
0
        public override void Load()
        {
            // These operations need to be performed on the GL thread.
            // This can be further optimized by creating the objects on another thread and then just passing them.
            GLThread.ExecuteGLThread(() =>
            {
                // Create a new map buffer.
                _buffer = new QuadMapBuffer(Renderer.MaxRenderable);

                // Map buffer.
                int x          = 0;
                int y          = 0;
                const int size = 5;
                for (int i = 0; i < Renderer.MaxRenderable; i++)
                {
                    // Add objects one after another of a random color.
                    Color randomColor = new Color(Utilities.GenerateRandomNumber(0, 255), Utilities.GenerateRandomNumber(0, 255), Utilities.GenerateRandomNumber(0, 255));
                    _buffer.MapNextQuad(new Vector3(x * size, y * size, 1), new Vector2(size, size), randomColor);

                    x++;
                    if (x * size < 960)
                    {
                        continue;
                    }
                    x = 0;
                    y++;
                }
            });
        }
Esempio n. 2
0
 /// <summary>
 /// Queue a render on the main map buffer.
 /// </summary>
 /// <param name="location">The location of the buffer.</param>
 /// <param name="size">The size of the buffer.</param>
 /// <param name="color">The color of the vertices.</param>
 /// <param name="texture">The texture to use.</param>
 /// <param name="textureArea">The texture area to render.</param>
 public void RenderQueue(Vector3 location, Vector2 size, Color color, Texture texture = null, Rectangle?textureArea = null)
 {
     _mainBuffer.MapNextQuad(location, size, color, texture, textureArea);
 }