bruh a little

This commit is contained in:
Ben
2019-10-05 20:39:37 +01:00
parent a112e8e4f1
commit 9451e02edd
10 changed files with 15208 additions and 12 deletions

View File

@@ -3,9 +3,11 @@
#define LOGGER_DEFINITION
#include <logger.h>
#include "renderer/shader.hpp"
#include "renderer/renderer.hpp"
#include "renderer/camera.hpp"
#include "world/world.hpp"
#include "common.hpp"
@@ -14,6 +16,7 @@ Game::Game() {
}
void Game::Setup(int w, int h) {
m_logger = std::make_shared<Logger>();
*m_logger << "----------------" << LOGGER_ENDL;
@@ -104,6 +107,7 @@ void Game::Setup(int w, int h) {
}
void Game::Input(SDL_Event* e) {
while (SDL_PollEvent(e))
if (e->type == SDL_QUIT)
IsDisplayOpen = false;
@@ -120,15 +124,13 @@ void Game::Run() {
const float clear[] = { 0.1f, 0.45f, 0.9f, 1.0f };
glClearBufferfv(GL_COLOR, 0, clear);
Shader shader;
shader.Load("E:/Games/minecraft/resources/shaders/simple");
shader.Use();
m_renderer = std::make_shared<Renderer>();
m_world = std::make_shared<World>();
while (IsDisplayOpen) {
Input(&e);
#ifdef __IMGUI
ImGui::NewFrame();
@@ -139,6 +141,8 @@ void Game::Run() {
#endif
glClear(GL_DEPTH_BUFFER_BIT);
m_renderer->Render(m_world , m_activeCamera);
#ifdef __IMGUI
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());

View File

@@ -1,7 +1,6 @@
#ifndef MINECRAFT_GAME_H_
#define MINECRAFT_GAME_H_
#ifdef NDEBUG
#define __DEBUG
#endif
@@ -13,6 +12,7 @@
#include <string>
#include <map>
#if _WIN32
#include <SDL.h>
#else
@@ -20,8 +20,10 @@
#endif
class Logger;
class Camera;
class Renderer;
class Camera;
class World;
class Game {
public:
@@ -42,6 +44,9 @@ private:
std::shared_ptr<Logger> m_logger;
std::shared_ptr<Renderer> m_renderer;
std::shared_ptr<World> m_world;
std::map<std::string, std::shared_ptr<Camera>> m_cameras;
std::shared_ptr<Camera> m_activeCamera;

View File

@@ -10,17 +10,16 @@ Camera::Camera() {
}
void Camera::UpdateView() {
// roll can be removed from here. because is not actually used in FPS camera
glm::mat4 matRoll = glm::mat4(1.0f);//identity matrix;
// roll can be removed
glm::mat4 matRoll = glm::mat4(1.0f); //identity matrix;
glm::mat4 matPitch = glm::mat4(1.0f);//identity matrix
glm::mat4 matYaw = glm::mat4(1.0f);//identity matrix
glm::mat4 matYaw = glm::mat4(1.0f); //identity matrix
// roll, pitch and yaw are used to store our angles in our class
// roll, pitch and yaw
matRoll = glm::rotate(matRoll, roll, glm::vec3(0.0f, 0.0f, 1.0f));
matPitch = glm::rotate(matPitch, pitch, glm::vec3(1.0f, 0.0f, 0.0f));
matYaw = glm::rotate(matYaw, yaw, glm::vec3(0.0f, 1.0f, 0.0f));
// order matters
glm::mat4 rotate = matRoll * matPitch * matYaw;
glm::mat4 translate = glm::mat4(1.0f);

11
src/renderer/face.hpp Normal file
View File

@@ -0,0 +1,11 @@
#ifndef MINECRAFT_RENDERER_FACE_H_
#define MINECRAFT_RENDERER_FACE_H_
class Face {
public:
};
#endif

12
src/renderer/renderer.cpp Normal file
View File

@@ -0,0 +1,12 @@
#include "renderer.hpp"
Renderer::Renderer() {
}
// Perform the render passes
void Renderer::Render(std::shared_ptr<World> world, std::shared_ptr<Camera> camera) {
}

18
src/renderer/renderer.hpp Normal file
View File

@@ -0,0 +1,18 @@
#ifndef MINECRAFT_RENDERER_RENDERER_H_
#define MINECRAFT_RENDERER_RENDERER_H_
#include "../common.hpp"
#include "../world/world.hpp"
#include "camera.hpp"
// Does GL render passes then returns to the game loop
class Renderer {
public:
Renderer();
void Render(std::shared_ptr<World> world, std::shared_ptr<Camera> camera);
};
#endif

7568
src/util/stb_image.hpp Normal file

File diff suppressed because it is too large Load Diff

7568
src/util/stb_image_write.hpp Normal file

File diff suppressed because it is too large Load Diff

3
src/world/world.cpp Normal file
View File

@@ -0,0 +1,3 @@
#include "world.hpp"

8
src/world/world.hpp Normal file
View File

@@ -0,0 +1,8 @@
#ifndef MINECRAFT_WORLD_WORLD_H_
#define MINECRAFT_WORLD_WORLD_H_
class World {
};
#endif