feat: basic castle rendering
This commit is contained in:
@@ -123,6 +123,34 @@ GL::VertexArray loadWorldModel(const td::game::World* world) {
|
||||
}
|
||||
}
|
||||
|
||||
for (int castleColor = 0; castleColor < 2; castleColor++) {
|
||||
const game::TeamCastle& castle = world->getTeam(game::TeamColor(castleColor)).getCastle();
|
||||
float fromX = castle.x - 2, toX = castle.x + 3;
|
||||
float fromY = castle.y - 2, toY = castle.y + 3;
|
||||
|
||||
positions.insert(positions.end(), {
|
||||
fromX, fromY,
|
||||
fromX, toY,
|
||||
toX, fromY,
|
||||
|
||||
toX, toY,
|
||||
fromX, toY,
|
||||
toX, fromY,
|
||||
});
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
int color = 255;
|
||||
color |= world->getSpawnColor(game::TeamColor(castleColor)).r << 24;
|
||||
color |= world->getSpawnColor(game::TeamColor(castleColor)).g << 16;
|
||||
color |= world->getSpawnColor(game::TeamColor(castleColor)).b << 8;
|
||||
|
||||
int newColorIndex = colors.size();
|
||||
colors.push_back(0);
|
||||
|
||||
memcpy(colors.data() + newColorIndex, &color, 1 * sizeof(int));
|
||||
}
|
||||
}
|
||||
|
||||
GL::VertexBuffer positionVBO(positions, 2);
|
||||
positionVBO.addVertexAttribPointer(0, 2, 0);
|
||||
GL::VertexBuffer colorVBO(colors, 1);
|
||||
|
||||
Reference in New Issue
Block a user