faces and that
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "renderer/renderer.hpp"
|
||||
#include "renderer/camera.hpp"
|
||||
#include "renderer/face.hpp"
|
||||
|
||||
#include "world/world.hpp"
|
||||
|
||||
@@ -124,8 +125,10 @@ void Game::Run() {
|
||||
const float clear[] = { 0.1f, 0.45f, 0.9f, 1.0f };
|
||||
glClearBufferfv(GL_COLOR, 0, clear);
|
||||
|
||||
m_renderer = std::make_shared<Renderer>();
|
||||
m_world = std::make_shared<World>();
|
||||
m_renderer = std::make_unique<Renderer>();
|
||||
m_world = std::make_unique<World>();
|
||||
|
||||
m_world->Faces.push_back(std::make_shared<Face>(FaceDirection::Top, 1));
|
||||
|
||||
while (IsDisplayOpen) {
|
||||
|
||||
|
||||
118
src/renderer/face.cpp
Normal file
118
src/renderer/face.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
#include "face.hpp"
|
||||
|
||||
Face::Face(FaceDirection direction, int textureID) {
|
||||
Direction = direction;
|
||||
Texture = textureID;
|
||||
|
||||
m_uvs = {
|
||||
{ 0.0f, 0.0f },
|
||||
{ 1.0f, 0.0f },
|
||||
{ 1.0f, 1.0f },
|
||||
{ 1.0f, 1.0f },
|
||||
{ 0.0f, 1.0f },
|
||||
{ 0.0f, 0.0f }
|
||||
};
|
||||
|
||||
switch (Direction) {case FaceDirection::Top:
|
||||
{
|
||||
|
||||
m_verticies = {
|
||||
{ -0.5f, -0.5f, -0.5f },
|
||||
{ 0.5f, -0.5f, -0.5f },
|
||||
{ 0.5f, 0.5f, -0.5f },
|
||||
{ 0.5f, 0.5f, -0.5f },
|
||||
{ -0.5f, 0.5f, -0.5f },
|
||||
{ -0.5f, -0.5f, -0.5f },
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case FaceDirection::Bottom:
|
||||
{
|
||||
|
||||
m_verticies = {
|
||||
{ -0.5f, -0.5f, 0.5f },
|
||||
{ 0.5f, -0.5f, 0.5f },
|
||||
{ 0.5f, 0.5f, 0.5f },
|
||||
{ 0.5f, 0.5f, 0.5f },
|
||||
{ -0.5f, 0.5f, 0.5f },
|
||||
{ -0.5f, -0.5f, 0.5f },
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case FaceDirection::Front:
|
||||
{
|
||||
|
||||
m_verticies = {
|
||||
{ -0.5f, 0.5f, 0.5f },
|
||||
{ -0.5f, 0.5f, -0.5f },
|
||||
{ -0.5f, -0.5f, -0.5f },
|
||||
{ -0.5f, -0.5f, -0.5f },
|
||||
{ -0.5f, -0.5f, 0.5f },
|
||||
{ -0.5f, 0.5f, 0.5f },
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case FaceDirection::Back:
|
||||
{
|
||||
|
||||
m_verticies = {
|
||||
{ 0.5f, 0.5f, 0.5f },
|
||||
{ 0.5f, 0.5f, -0.5f },
|
||||
{ 0.5f, -0.5f, -0.5f },
|
||||
{ 0.5f, -0.5f, -0.5f },
|
||||
{ 0.5f, -0.5f, 0.5f },
|
||||
{ 0.5f, 0.5f, 0.5f },
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case FaceDirection::Left:
|
||||
{
|
||||
|
||||
m_verticies = {
|
||||
{ -0.5f, -0.5f, -0.5f },
|
||||
{ 0.5f, -0.5f, -0.5f },
|
||||
{ 0.5f, -0.5f, 0.5f },
|
||||
{ 0.5f, -0.5f, 0.5f },
|
||||
{ -0.5f, -0.5f, 0.5f },
|
||||
{ -0.5f, -0.5f, -0.5f },
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
case FaceDirection::Right:
|
||||
{
|
||||
|
||||
m_verticies = {
|
||||
{ -0.5f, 0.5f, -0.5f },
|
||||
{ 0.5f, 0.5f, -0.5f },
|
||||
{ 0.5f, 0.5f, 0.5f },
|
||||
{ 0.5f, 0.5f, 0.5f },
|
||||
{ -0.5f, 0.5f, 0.5f },
|
||||
{ -0.5f, 0.5f, -0.5f },
|
||||
};
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
void Face::GetMesh(std::vector<glm::vec3>& verts, std::vector<glm::vec2>& uvs) {
|
||||
|
||||
}
|
||||
@@ -1,10 +1,31 @@
|
||||
#ifndef MINECRAFT_RENDERER_FACE_H_
|
||||
#define MINECRAFT_RENDERER_FACE_H_
|
||||
|
||||
#include "../common.hpp"
|
||||
|
||||
enum FaceDirection {
|
||||
Top,
|
||||
Bottom,
|
||||
Front,
|
||||
Back,
|
||||
Left,
|
||||
Right
|
||||
};
|
||||
|
||||
class Face {
|
||||
public:
|
||||
Face(FaceDirection direction, int textureID);
|
||||
|
||||
void GetMesh(std::vector<glm::vec3>& verts, std::vector<glm::vec2>& uvs);
|
||||
|
||||
int Texture = 0;
|
||||
|
||||
FaceDirection Direction = FaceDirection::Up;
|
||||
|
||||
private:
|
||||
|
||||
std::vector<glm::vec3> m_verticies;
|
||||
std::vector<glm::vec2> m_uvs;
|
||||
|
||||
};
|
||||
|
||||
|
||||
0
src/renderer/texture.cpp
Normal file
0
src/renderer/texture.cpp
Normal file
0
src/renderer/texture.hpp
Normal file
0
src/renderer/texture.hpp
Normal file
@@ -1,7 +1,14 @@
|
||||
#ifndef MINECRAFT_WORLD_WORLD_H_
|
||||
#define MINECRAFT_WORLD_WORLD_H_
|
||||
|
||||
#include "../common.hpp"
|
||||
|
||||
class Face;
|
||||
|
||||
class World {
|
||||
public:
|
||||
|
||||
std::vector<std::shared_ptr<Face>> Faces;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user