예제 #1
0
 private void UpdateBuffer()
 {
     if (BackColor)
     {
         for (int i = 0; i < drawCount; i++)
         {
             Vector2 uv  = TiledTexture.GetUV(tiles[i]);
             int     i10 = i * 10;
             tileVertices[i10]     = uv[0];
             tileVertices[i10 + 1] = uv[1];
             tileVertices[i10 + 2] = colors[i][0];
             tileVertices[i10 + 3] = colors[i][1];
             tileVertices[i10 + 4] = colors[i][2];
             tileVertices[i10 + 5] = colors[i][3];
             tileVertices[i10 + 6] = backColors[i][0];
             tileVertices[i10 + 7] = backColors[i][1];
             tileVertices[i10 + 8] = backColors[i][2];
             tileVertices[i10 + 9] = backColors[i][3];
         }
     }
     else
     {
         for (int i = 0; i < drawCount; i++)
         {
             Vector2 uv  = TiledTexture.GetUV(tiles[i]);
             int     i10 = i * 6;
             tileVertices[i10]     = uv[0];
             tileVertices[i10 + 1] = uv[1];
             tileVertices[i10 + 2] = colors[i][0];
             tileVertices[i10 + 3] = colors[i][1];
             tileVertices[i10 + 4] = colors[i][2];
             tileVertices[i10 + 5] = colors[i][3];
         }
     }
     GLStates.BindBuffer(BufferTarget.ArrayBuffer, tileBO);
     GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(tileVertices.Length * sizeof(float)), tileVertices, BufferUsageHint.DynamicDraw);
 }
예제 #2
0
        private void UpdateBuffer()
        {
            for (int i = 0; i < Sprites.Count; i++)
            {
                int     i2 = i * 13;
                Vector2 uv = TiledTexture.GetUV(Sprites[i].tile);

                //sprite_position
                bufferObject.Data[i2]     = Sprites[i].position.X;
                bufferObject.Data[i2 + 1] = Sprites[i].position.Y;

                //Size
                bufferObject.Data[i2 + 2] = Sprites[i].size.X;
                bufferObject.Data[i2 + 3] = Sprites[i].size.Y;

                //Texture
                bufferObject.Data[i2 + 4] = uv.X;
                bufferObject.Data[i2 + 5] = uv.Y;

                //Scale
                bufferObject.Data[i2 + 6] = Sprites[i].scale.X;
                bufferObject.Data[i2 + 7] = Sprites[i].scale.Y;

                //Rotation
                bufferObject.Data[i2 + 8] = Sprites[i].rotation;

                //Color
                bufferObject.Data[i2 + 9]  = Sprites[i].color[0];
                bufferObject.Data[i2 + 10] = Sprites[i].color[1];
                bufferObject.Data[i2 + 11] = Sprites[i].color[2];
                bufferObject.Data[i2 + 12] = Sprites[i].color[3];
            }

            GLStates.BindBuffer(BufferTarget.ArrayBuffer, bufferObject.Id);
            GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)0, (IntPtr)(Sprites.Count * 13 * sizeof(float)), bufferObject.Data);
        }