public static FastCreateQuad ( |
||
vertices | ||
o | float2 | |
r | ||
paletteTextureIndex | float | |
nv | int | |
size | float2 | |
return | void |
public void Update(MPos uv, Sprite sprite, float3 pos) { if (sprite != null) { if (sprite.Sheet != Sheet) { throw new InvalidDataException("Attempted to add sprite from a different sheet"); } if (sprite.BlendMode != BlendMode) { throw new InvalidDataException("Attempted to add sprite with a different blend mode"); } } else { sprite = emptySprite; } // The vertex buffer does not have geometry for cells outside the map if (!map.Tiles.Contains(uv)) { return; } var offset = rowStride * uv.V + 6 * uv.U; Util.FastCreateQuad(vertices, pos, sprite, int2.Zero, palette.TextureIndex, offset, sprite.Size); dirtyRows.Add(uv.V); }
public void Update(MPos uv, Sprite sprite, float2 pos) { if (sprite != null) { if (sprite.Sheet != Sheet) { throw new InvalidDataException("Attempted to add sprite from a different sheet"); } if (sprite.BlendMode != BlendMode) { throw new InvalidDataException("Attempted to add sprite with a different blend mode"); } } else { sprite = emptySprite; } var offset = rowStride * uv.V + 4 * uv.U; Util.FastCreateQuad(vertices, pos, sprite, palette.TextureIndex, offset, sprite.Size); dirtyRows.Add(uv.V); }
public void DrawSpriteWithTint(Sprite s, float3 a, float3 b, float3 c, float3 d, float3 tint) { var samplers = SetRenderStateForSprite(s); Util.FastCreateQuad(vertices, a, b, c, d, s, samplers, 0, tint, nv); nv += 6; }
internal void DrawSpriteWithTint(Sprite s, float3 location, float paletteTextureIndex, float3 size, float3 tint) { var samplers = SetRenderStateForSprite(s); Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, samplers, paletteTextureIndex, nv, size, tint); nv += 6; }
void GenerateTileVertices(Vertex[] vertices, int offset, CPos cell) { var tile = theater.TileSprite(mapTiles[cell]); var pos = worldRenderer.ScreenPosition(map.CenterOfCell(cell)) + tile.Offset - 0.5f * tile.Size; Util.FastCreateQuad(vertices, pos, tile, terrainPaletteIndex, offset, tile.Size); }
public void DrawTextSprite(Sprite s, float3 location, float paletteTextureIndex, float3 size) { var samplers = SetRenderStateForSprite(s); // узнает номер текстуры из которой этой спрайт в переменную samplers, чтобы потом записать это в VBO Util.FastCreateQuad(vertices, location, s, samplers, paletteTextureIndex, nv, size); nv += 6; }
public void DrawSprite(Sprite s, float2 location, int paletteIndex, float2 size) { Renderer.CurrentBatchRenderer = this; if (s.sheet != currentSheet) { Flush(); } if (nv + 4 > Renderer.TempBufferSize) { Flush(); } currentSheet = s.sheet; Util.FastCreateQuad(vertices, location.ToInt2(), s, paletteIndex, nv, size); nv += 4; }
public TerrainRenderer(World world, WorldRenderer wr) { this.world = world; this.map = world.Map; var terrainPalette = wr.Palette("terrain").Index; var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width]; var nv = 0; foreach (var cell in map.Cells) { var tile = wr.Theater.TileSprite(map.MapTiles.Value[cell]); var pos = wr.ScreenPosition(map.CenterOfCell(cell)) - 0.5f * tile.size; Util.FastCreateQuad(vertices, pos, tile, terrainPalette, nv, tile.size); nv += 4; } vertexBuffer = Game.Renderer.Device.CreateVertexBuffer(vertices.Length); vertexBuffer.SetData(vertices, nv); }
public void Update(MPos uv, Sprite sprite, float3 pos) { if (sprite != null) { //if (sprite.Sheet != Sheet) // throw new InvalidDataException("Attempted to add sprite from a different sheet"); if (sprite.BlendMode != BlendMode) { throw new InvalidDataException("Attempted to add sprite with a different blend mode"); } } else { sprite = emptySprite; } // The vertex buffer does not have geometry for cells outside the map if (!map.Tiles.Contains(uv)) { return; } SamplerPointer textslot; var offset = TerrainFullRowLenInVertexRowsNums * uv.V + 6 * uv.U; if (sprite.SpriteType == 4) //megaTexture { Sprite tmpsp = new Sprite(sprite.Sheet, new Rectangle((int)pos.X, (int)pos.Y, 16, 16), TextureChannel.RGBA); tmpsp.SpriteType = 4; textslot = SetRenderStateForSprite(tmpsp); Util.FastCreateQuad(vertices, pos, tmpsp, textslot, palette.TextureIndex, offset, tmpsp.Size); } else { textslot = SetRenderStateForSprite(sprite); Util.FastCreateQuad(vertices, pos, sprite, textslot, palette.TextureIndex, offset, sprite.Size); } dirtyRows.Add(uv.V); }
public TerrainRenderer(World world, WorldRenderer wr) { this.world = world; this.map = world.Map; var terrainPalette = wr.Palette("terrain").Index; var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width]; int nv = 0; for (var j = map.Bounds.Top; j < map.Bounds.Bottom; j++) { for (var i = map.Bounds.Left; i < map.Bounds.Right; i++) { var tile = wr.Theater.TileSprite(map.MapTiles.Value[i, j]); Util.FastCreateQuad(vertices, Game.CellSize * new float2(i, j), tile, terrainPalette, nv, tile.size); nv += 4; } } vertexBuffer = Game.Renderer.Device.CreateVertexBuffer(vertices.Length); vertexBuffer.SetData(vertices, nv); }
public TerrainRenderer(World world, WorldRenderer wr) { this.world = world; this.map = world.Map; var tileSize = new Size(Game.CellSize, Game.CellSize); var tileMapping = new Cache <TileReference <ushort, byte>, Sprite>( x => Game.modData.SheetBuilder.Add(world.TileSet.GetBytes(x), tileSize)); var vertices = new Vertex[4 * map.Bounds.Height * map.Bounds.Width]; terrainSheet = tileMapping[map.MapTiles.Value[map.Bounds.Left, map.Bounds.Top]].sheet; int nv = 0; var terrainPalette = wr.Palette("terrain").Index; for (int j = map.Bounds.Top; j < map.Bounds.Bottom; j++) { for (int i = map.Bounds.Left; i < map.Bounds.Right; i++) { var tile = tileMapping[map.MapTiles.Value[i, j]]; // TODO: move GetPaletteIndex out of the inner loop. Util.FastCreateQuad(vertices, Game.CellSize * new float2(i, j), tile, terrainPalette, nv, tile.size); nv += 4; if (tileMapping[map.MapTiles.Value[i, j]].sheet != terrainSheet) { throw new InvalidOperationException("Terrain sprites span multiple sheets. Try increasing Game.Settings.Graphics.SheetSize."); } } } vertexBuffer = Game.Renderer.Device.CreateVertexBuffer(vertices.Length); vertexBuffer.SetData(vertices, nv); }
public void DrawSprite(Sprite s, float2 a, float2 b, float2 c, float2 d) { Renderer.CurrentBatchRenderer = this; if (s.sheet != currentSheet) { Flush(); } if (s.blendMode != currentBlend) { Flush(); } if (nv + 4 > Renderer.TempBufferSize) { Flush(); } currentSheet = s.sheet; currentBlend = s.blendMode; Util.FastCreateQuad(vertices, a, b, c, d, s, 0, nv); nv += 4; }
void DrawSprite(Sprite s, float2 location, int paletteIndex, float2 size) { Renderer.CurrentBatchRenderer = this; if (s.sheet != currentSheet) { Flush(); } if (s.blendMode != currentBlend) { Flush(); } if (nv + 4 > Renderer.TempBufferSize) { Flush(); } currentBlend = s.blendMode; currentSheet = s.sheet; Util.FastCreateQuad(vertices, location + s.offset, s, paletteIndex, nv, size); nv += 4; }
public void DrawSprite(Sprite s, float2 a, float2 b, float2 c, float2 d) { SetRenderStateForSprite(s); Util.FastCreateQuad(vertices, a, b, c, d, s, 0, nv); nv += 4; }
void DrawSprite(Sprite s, float2 location, float paletteTextureIndex, float2 size) { SetRenderStateForSprite(s); Util.FastCreateQuad(vertices, location + s.FractionalOffset * size, s, paletteTextureIndex, nv, size); nv += 4; }