14{
18
19 m_filePath = skyboxFilePath;
20
21
23 m_VertexBuffer->SetLayout({
25 });
26
29 m_VertexArray->AddVertexBuffer(m_VertexBuffer);
30 m_VertexArray->SetIndexBuffer(m_IndexBuffer);
31 m_VertexArray->Unbind();
32
33
35#include "ElevateEngine/Renderer/Cubemap/skybox.vert"
36 ;
38#include "ElevateEngine/Renderer/Cubemap/skybox.frag"
39 ;
41
42
43 GLCheck(glGenTextures(1, &m_textureID));
44 GLCheck(glBindTexture(GL_TEXTURE_CUBE_MAP, m_textureID));
45
46 int width, height, nrChannels;
47 for (int i = 0; i < 6; i++)
48 {
49 unsigned char* data = stbi_load(paths[i].c_str(), &width, &height, &nrChannels, 0);
50 if (data)
51 {
52 GLCheck(glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data));
53 stbi_image_free(data);
54 }
55 else
56 {
57 EE_CORE_ERROR("Error : Unable to load cubemap texture [{}] : {} with the following skybox file : {}", i, paths[i].c_str(), skyboxFilePath);
58 return;
59 }
60 }
61 GLCheck(glGenerateMipmap(GL_TEXTURE_CUBE_MAP));
62
63 GLCheck(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR));
64 GLCheck(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR));
65 GLCheck(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE));
66 GLCheck(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE));
67 GLCheck(glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE));
68}
static IndexBuffer * Create(const void *vertices, uint32_t count)
static std::shared_ptr< Shader > Create(const std::string &vertexSource, const std::string &fragmentSouce)
static VertexArray * Create()
static VertexBuffer * Create(const void *vertices, const uint32_t size)