62 lines
2.2 KiB
C++
62 lines
2.2 KiB
C++
#ifndef HYDRACREATECUBEMAPSHADOWFRAMEBUFFER
|
|
#define HYDRACREATECUBEMAPSHADOWFRAMEBUFFER
|
|
|
|
#include "../HydraTask.h"
|
|
#include "../../engine/HydraEngine.h"
|
|
#include "../../renderer/HydraRenderer.h"
|
|
#include <GLMIncludes.h>
|
|
#include "../../GlewIncludes.h"
|
|
#include "../../buffer/HydraTextureBufferManager.h"
|
|
|
|
class HydraCreateCubemapShadowFrameBuffer : public HydraTask
|
|
{
|
|
private:
|
|
uint32_t *m_texture_id = 0;
|
|
uint32_t *m_depth_texture_id = 0;
|
|
uint32_t *m_frame_buffer_id = nullptr;
|
|
|
|
protected:
|
|
public:
|
|
void Process() override
|
|
{
|
|
HydraEngine *engine = GetEngine();
|
|
|
|
HydraTextureBufferManager *tex_buffer_manager = engine->TextureBufferManager();
|
|
HydraRenderSettings render_settings = engine->RenderSettings();
|
|
|
|
HydraTextureBuffer texture = tex_buffer_manager->GetTexture(*m_texture_id);
|
|
|
|
*m_depth_texture_id = tex_buffer_manager->CreateCubemapTexture("shadow_depth_buffer",
|
|
SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
|
|
GL_DEPTH_COMPONENT32F,
|
|
GL_NEAREST,
|
|
GL_NEAREST);
|
|
|
|
HydraTextureBuffer depth_texture = tex_buffer_manager->GetTexture(*m_depth_texture_id);
|
|
glCreateFramebuffers(1, m_frame_buffer_id);
|
|
glBindFramebuffer(GL_FRAMEBUFFER, *m_frame_buffer_id);
|
|
|
|
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depth_texture.gl_tex_id, 0);
|
|
|
|
glDrawBuffer(GL_NONE);
|
|
glReadBuffer(GL_NONE);
|
|
|
|
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
|
if (status != GL_FRAMEBUFFER_COMPLETE)
|
|
{
|
|
std::cout << "Framebuffer error: " << status << std::endl;
|
|
}
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
tex_buffer_manager->BindTexture(*m_depth_texture_id, GL_TEXTURE_CUBE_MAP);
|
|
}
|
|
void Initialise(uint32_t *texture_id, uint32_t *depth_texture_id, uint32_t *frame_buffer_id)
|
|
{
|
|
m_texture_id = texture_id;
|
|
m_frame_buffer_id = frame_buffer_id;
|
|
m_depth_texture_id = depth_texture_id;
|
|
}
|
|
};
|
|
|
|
|
|
#endif /* HYDRACREATECUBEMAPSHADOWFRAMEBUFFER */
|