kinda 3d
This commit is contained in:
@@ -10,15 +10,17 @@ namespace render {
|
||||
|
||||
namespace WorldLoader {
|
||||
|
||||
const static int VERTEX_SIZE = 3;
|
||||
|
||||
GL::VertexArray LoadMobModel() {
|
||||
std::vector<float> positions = {
|
||||
-0.5, -0.5,
|
||||
0.5, -0.5,
|
||||
-0.5, 0.5,
|
||||
-0.5, 0, -0.5,
|
||||
0.5, 0, -0.5,
|
||||
-0.5, 0, 0.5,
|
||||
|
||||
0.5, -0.5,
|
||||
-0.5, 0.5,
|
||||
0.5, 0.5
|
||||
0.5, 0, -0.5,
|
||||
-0.5, 0, 0.5,
|
||||
0.5, 0, 0.5
|
||||
};
|
||||
|
||||
float yellowFloat;
|
||||
@@ -35,8 +37,8 @@ GL::VertexArray LoadMobModel() {
|
||||
yellowFloat
|
||||
};
|
||||
|
||||
GL::VertexBuffer positionVBO(positions, 2);
|
||||
positionVBO.AddVertexAttribPointer(0, 2, 0);
|
||||
GL::VertexBuffer positionVBO(positions, VERTEX_SIZE);
|
||||
positionVBO.AddVertexAttribPointer(0, VERTEX_SIZE, 0);
|
||||
GL::VertexBuffer colorVBO(colors, 1);
|
||||
colorVBO.AddVertexAttribPointer(1, 1, 0);
|
||||
|
||||
@@ -69,13 +71,13 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||
continue;
|
||||
|
||||
positions.insert(positions.end(), {
|
||||
static_cast<float>(chunkX + tileX), static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX + 1), static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX), static_cast<float>(chunkY + tileY + 1),
|
||||
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY + 1),
|
||||
|
||||
static_cast<float>(chunkX + tileX + 1), static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX), static_cast<float>(chunkY + tileY + 1),
|
||||
static_cast<float>(chunkX + tileX + 1), static_cast<float>(chunkY + tileY + 1),
|
||||
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY),
|
||||
static_cast<float>(chunkX + tileX), 0, static_cast<float>(chunkY + tileY + 1),
|
||||
static_cast<float>(chunkX + tileX + 1), 0, static_cast<float>(chunkY + tileY + 1)
|
||||
});
|
||||
|
||||
const td::Color* tileColor = world->GetTileColor(tile);
|
||||
@@ -101,13 +103,13 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||
float fromY = spawn.GetTopLeft().GetY(), toY = spawn.GetBottomRight().GetY();
|
||||
|
||||
positions.insert(positions.end(), {
|
||||
fromX, fromY,
|
||||
fromX, toY,
|
||||
toX, fromY,
|
||||
fromX, 0, fromY,
|
||||
fromX, 0, toY,
|
||||
toX, 0, fromY,
|
||||
|
||||
toX, toY,
|
||||
fromX, toY,
|
||||
toX, fromY,
|
||||
toX, 0, toY,
|
||||
fromX, 0, toY,
|
||||
toX, 0, fromY,
|
||||
});
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
@@ -129,13 +131,13 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||
float fromY = castle.GetTopLeft().GetY(), toY = castle.GetBottomRight().GetY();
|
||||
|
||||
positions.insert(positions.end(), {
|
||||
fromX, fromY,
|
||||
fromX, toY,
|
||||
toX, fromY,
|
||||
fromX, 0, fromY,
|
||||
fromX, 0, toY,
|
||||
toX, 0, fromY,
|
||||
|
||||
toX, toY,
|
||||
fromX, toY,
|
||||
toX, fromY,
|
||||
toX, 0, toY,
|
||||
fromX, 0, toY,
|
||||
toX, 0, fromY,
|
||||
});
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
@@ -151,12 +153,12 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||
}
|
||||
}
|
||||
|
||||
GL::VertexBuffer positionVBO(positions, 2);
|
||||
positionVBO.AddVertexAttribPointer(0, 2, 0);
|
||||
GL::VertexBuffer positionVBO(positions, VERTEX_SIZE);
|
||||
positionVBO.AddVertexAttribPointer(0, VERTEX_SIZE, 0);
|
||||
GL::VertexBuffer colorVBO(colors, 1);
|
||||
colorVBO.AddVertexAttribPointer(1, 1, 0);
|
||||
|
||||
GL::VertexArray worldVao(positions.size() / 2); // each pos = 2 vertecies
|
||||
GL::VertexArray worldVao(positions.size() / VERTEX_SIZE); // each pos = 3 vertecies
|
||||
worldVao.Bind();
|
||||
worldVao.BindVertexBuffer(positionVBO);
|
||||
worldVao.BindVertexBuffer(colorVBO);
|
||||
@@ -166,13 +168,13 @@ GL::VertexArray LoadWorldModel(const td::game::World* world) {
|
||||
|
||||
GL::VertexArray LoadTileSelectModel() {
|
||||
std::vector<float> positions = {
|
||||
0, 0,
|
||||
1, 0,
|
||||
0, 1,
|
||||
0, 0, 0,
|
||||
1, 0, 0,
|
||||
0, 0, 1,
|
||||
|
||||
1, 0,
|
||||
0, 1,
|
||||
1, 1
|
||||
1, 0, 0,
|
||||
0, 0, 1,
|
||||
1, 0, 1
|
||||
};
|
||||
|
||||
int color = 255 << 24 | 255 << 16 | 255 << 8 | 150;
|
||||
@@ -182,8 +184,8 @@ GL::VertexArray LoadTileSelectModel() {
|
||||
|
||||
std::vector<float> colors(6, colorFloat);
|
||||
|
||||
GL::VertexBuffer positionVBO(positions, 2);
|
||||
positionVBO.AddVertexAttribPointer(0, 2, 0);
|
||||
GL::VertexBuffer positionVBO(positions, VERTEX_SIZE);
|
||||
positionVBO.AddVertexAttribPointer(0, VERTEX_SIZE, 0);
|
||||
GL::VertexBuffer colorVBO(colors, 1);
|
||||
colorVBO.AddVertexAttribPointer(1, 1, 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user