Commit 8ee93438 authored by Adam Štěpánek's avatar Adam Štěpánek
Browse files

Fix Skybox

parent f2db136c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ add_executable(final
	src/main.cpp 
	src/application.cpp
	src/playback.cpp
	src/skybox.cpp
)

add_dependencies(final 
+8 −0
Original line number Diff line number Diff line
@@ -8,6 +8,14 @@

class Mesh {
public:
	Mesh(std::vector<float> vertices,
	    Material* material = nullptr)
	    : Mesh(vertices,
	          std::vector<float>(),
	          std::vector<float>(),
	          std::vector<uint32_t>(),
	          material) {
	}
	Mesh(std::vector<float> vertices,
	    std::vector<uint32_t> indices,
	    Material* material = nullptr)
+4 −4
Original line number Diff line number Diff line
@@ -6,12 +6,12 @@
class Texture {
public:
	Texture(const std::string& path);
	Texture(const std::string& up,
	Texture(const std::string& front,
	    const std::string& back,
	    const std::string& up,
	    const std::string& down,
	    const std::string& left,
	    const std::string& right,
	    const std::string& top,
	    const std::string& bottom);
	    const std::string& left);
	~Texture();

private:
+7 −5
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
#include <vector>

Texture::Texture(const std::string& filename) {

	int width, height, channels;
	stbi_set_flip_vertically_on_load(true);
	unsigned char* data = stbi_load(filename.c_str(), &width, &height, &channels, 4);
@@ -38,16 +39,17 @@ Texture::Texture(const std::string& filename) {
	glTextureParameteri(_id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}

Texture::Texture(const std::string& up,
Texture::Texture(const std::string& front,
    const std::string& back,
    const std::string& up,
    const std::string& down,
    const std::string& left,
    const std::string& right,
    const std::string& top,
    const std::string& bottom) {
    const std::string& left) {

	glCreateTextures(GL_TEXTURE_CUBE_MAP, 1, &_id);

	const char* faces[] {
		up.c_str(), down.c_str(), left.c_str(), right.c_str(), top.c_str(), bottom.c_str()
		front.c_str(), back.c_str(), up.c_str(), down.c_str(), right.c_str(), left.c_str()
	};

	unsigned char* faceData[6];
+1 −5
Original line number Diff line number Diff line
@@ -116,11 +116,7 @@ void Application::render() {
	glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, lightsBuffer);

	// Draw the skybox
	glDepthMask(GL_FALSE);
	glUseProgram(skyboxProgram.id());
	glBindTextureUnit(0, skybox.id());
	cube.draw();
	glDepthMask(GL_TRUE);
	skybox.draw();

	// Draw Jupiter
	glUseProgram(jupiterProgram.id());
Loading