Skip to content

Commit

Permalink
Added skybox textures
Browse files Browse the repository at this point in the history
  • Loading branch information
dorosch committed Sep 11, 2022
1 parent c435ac7 commit bee790a
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 130 deletions.
Binary file added resources/textures/skybox/default/back.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/textures/skybox/default/bottom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/textures/skybox/default/front.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/textures/skybox/default/left.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/textures/skybox/default/right.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/textures/skybox/default/top.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 6 additions & 130 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
#include <optional>
#include <functional>
#include <memory>
#include <vector>
#include <iostream>
#include <fmt/format.h>
#include <string>
#include <fstream>
#include <streambuf>
#include <filesystem>
#include <iostream>

#define GLEW_STATIC
#define GLM_FORCE_RADIANS
#include <GL/glew.h>
#include <glm/glm.hpp>
#include <glm/gtx/string_cast.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <SOIL/SOIL.h>

#include "engine.hpp"
#include "app.hpp"
#include "meta.hpp"
#include "editor.hpp"
#include "tools/model.hpp"
#include "tools/logger.hpp"
#include "tools/debug/axes/base.hpp"
#include "tools/debug/grid/base.hpp"
#include "core/render/buffer/base.hpp"
#include "core/render/shader/base.hpp"
#include "core/render/texture/base.hpp"
#include "core/render/texture/cubemap/base.hpp"
#include "core/scene/scene.hpp"
#include "core/object/object.hpp"
#include "core/window/base.hpp"
#include "core/window/glfw.hpp"
#include "core/event/observer.hpp"
#include "core/geometry/primitives.hpp"
#include "core/graphics/lighting/base.hpp"
#include "core/graphics/cameras/camera.hpp"
Expand Down Expand Up @@ -185,11 +158,6 @@ void window_size_callback(GLFWwindow* window, int width, int height) {

class UserApplication : public Engine::EngineApplication {
public:
// Engine::Render::Cubemap *cubemap;
// Engine::Render::ShaderProgram *skyboxShader = nullptr;
// std::unique_ptr<Engine::Render::VertexArray> skyboxVAO;
// std::unique_ptr<Engine::Render::VertexBuffer> skyboxVBO;

Tool::Debug::DebugAxes *debugAxes = nullptr;
Tool::Debug::DebugFloorGrid *debugFloorGrid = nullptr;

Expand Down Expand Up @@ -221,82 +189,6 @@ class UserApplication : public Engine::EngineApplication {
camera = std::make_unique<Engine::Graphics::Camera::Camera>();
cameraController = std::make_unique<CameraController>(camera.get());

// std::filesystem::path cwd = std::filesystem::current_path();

// this->skyboxShader = Engine::Render::ShaderProgram::GetInstance();
// this->skyboxShader->Build(
// cwd / "resources" / "shaders" / "skybox" / "shader.vert",
// cwd / "resources" / "shaders" / "skybox" / "shader.frag"
// );

// float skyboxVertices[] = {
// // positions
// -1000.0f, 1000.0f, -1000.0f,
// -1000.0f, -1000.0f, -1000.0f,
// 1000.0f, -1000.0f, -1000.0f,
// 1000.0f, -1000.0f, -1000.0f,
// 1000.0f, 1000.0f, -1000.0f,
// -1000.0f, 1000.0f, -1000.0f,

// -1000.0f, -1000.0f, 1000.0f,
// -1000.0f, -1000.0f, -1000.0f,
// -1000.0f, 1000.0f, -1000.0f,
// -1000.0f, 1000.0f, -1000.0f,
// -1000.0f, 1000.0f, 1000.0f,
// -1000.0f, -1000.0f, 1000.0f,

// 1000.0f, -1000.0f, -1000.0f,
// 1000.0f, -1000.0f, 1000.0f,
// 1000.0f, 1000.0f, 1000.0f,
// 1000.0f, 1000.0f, 1000.0f,
// 1000.0f, 1000.0f, -1000.0f,
// 1000.0f, -1000.0f, -1000.0f,

// -1000.0f, -1000.0f, 1000.0f,
// -1000.0f, 1000.0f, 1000.0f,
// 1000.0f, 1000.0f, 1000.0f,
// 1000.0f, 1000.0f, 1000.0f,
// 1000.0f, -1000.0f, 1000.0f,
// -1000.0f, -1000.0f, 1000.0f,

// -1000.0f, 1000.0f, -1000.0f,
// 1000.0f, 1000.0f, -1000.0f,
// 1000.0f, 1000.0f, 1000.0f,
// 1000.0f, 1000.0f, 1000.0f,
// -1000.0f, 1000.0f, 1000.0f,
// -1000.0f, 1000.0f, -1000.0f,

// -1000.0f, -1000.0f, -1000.0f,
// -1000.0f, -1000.0f, 1000.0f,
// 1000.0f, -1000.0f, -1000.0f,
// 1000.0f, -1000.0f, -1000.0f,
// -1000.0f, -1000.0f, 1000.0f,
// 1000.0f, -1000.0f, 1000.0f
// };
// std::vector<std::filesystem::path> faces = {
// cwd / "resources" / "textures" / "skybox" / "default" / "right.jpg",
// cwd / "resources" / "textures" / "skybox" / "default" / "left.jpg",
// cwd / "resources" / "textures" / "skybox" / "default" / "top.jpg",
// cwd / "resources" / "textures" / "skybox" / "default" / "bottom.jpg",
// cwd / "resources" / "textures" / "skybox" / "default" / "front.jpg",
// cwd / "resources" / "textures" / "skybox" / "default" / "back.jpg"
// };
// cubemap = Engine::Render::Cubemap::GetInstance();
// cubemap->Build(faces);

// // Bind skybox
// this->skyboxVAO = Engine::Render::VertexArray::GetInstance();
// this->skyboxVBO = Engine::Render::VertexBuffer::GetInstance();

// this->skyboxVAO->bind();
// this->skyboxVBO->bind(skyboxVertices, sizeof(skyboxVertices));

// this->skyboxVAO->layout(3, 3 * sizeof(float), 0);

// this->skyboxVBO->unbind();
// this->skyboxVAO->unbind();
// // End skybox

// Add geometry primitives to the scene
std::shared_ptr<Engine::Geometry::Plane> plane = std::make_shared<Engine::Geometry::Plane>();
std::shared_ptr<Engine::Geometry::Cube> cube = std::make_shared<Engine::Geometry::Cube>();
Expand Down Expand Up @@ -358,30 +250,14 @@ class UserApplication : public Engine::EngineApplication {
view = camera->getViewMatrix();
projection = camera->getProjectionMatrix();

render->RenderScene(scene, projection * view * model, camera->position);
// TODO: Move to the editor as debug flag
this->debugAxes->SetMVP(projection * view);
this->debugAxes->Enable();

// // Draw skybox
// glDepthFunc(GL_LEQUAL);
// skyboxShader->Use();
// this->skyboxShader->UniformMatrix("view", view);
// this->skyboxShader->UniformMatrix("projection", projection);
// glBindTexture(GL_TEXTURE_CUBE_MAP, cubemap->object);
this->debugFloorGrid->SetMVP(projection * view);
this->debugFloorGrid->Enable();

// this->skyboxVAO->bind();

// glDrawArrays(GL_TRIANGLES, 0, 36);

// this->skyboxVAO->unbind();

// glDepthFunc(GL_LESS);
// // End skybox

// TODO: Move to the editor as debug flag
// this->debugAxes->SetMVP(projection * view);
// this->debugAxes->Enable();

// this->debugFloorGrid->SetMVP(projection * view);
// this->debugFloorGrid->Enable();
render->RenderScene(scene, projection * view * model, camera->position);
}

void Shutdown() {
Expand Down

0 comments on commit bee790a

Please sign in to comment.