Shadow buffer
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
#ifndef HYDRABEGINRENDERTASK
|
||||
#define HYDRABEGINRENDERTASK
|
||||
#include "../HydraTask.h"
|
||||
#include "../../engine/HydraEngine.h"
|
||||
#include "../../renderer/HydraRenderer.h"
|
||||
|
||||
class HydraBeginRenderTask : public HydraTask
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
public:
|
||||
virtual void Process() override
|
||||
{
|
||||
GetEngine()->Renderer()->BeginFrame();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif /* HYDRABEGINRENDERTASK */
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef HYDRACREATESHADOWFRAMEBUFFER
|
||||
#define HYDRACREATESHADOWFRAMEBUFFER
|
||||
|
||||
#include "../HydraTask.h"
|
||||
#include "../../engine/HydraEngine.h"
|
||||
#include "../../renderer/HydraRenderer.h"
|
||||
#include <GLMIncludes.h>
|
||||
#include "../../GlewIncludes.h"
|
||||
|
||||
class HydraCreateShadowFrameBuffer : public HydraTask
|
||||
{
|
||||
private:
|
||||
uint32_t *m_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();
|
||||
|
||||
*m_texture_id = tex_buffer_manager->CreateTextureArray("shadow_FB",
|
||||
SHADOW_MAP_SIZE, SHADOW_MAP_SIZE,
|
||||
GL_DEPTH_COMPONENT24,
|
||||
GL_NEAREST,
|
||||
GL_NEAREST,
|
||||
6);
|
||||
|
||||
HydraTextureBuffer texture = tex_buffer_manager->GetTexture(*m_texture_id);
|
||||
|
||||
glGenFramebuffers(1, m_frame_buffer_id);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, *m_frame_buffer_id);
|
||||
|
||||
glNamedFramebufferDrawBuffer(*m_frame_buffer_id, GL_NONE);
|
||||
glNamedFramebufferReadBuffer(*m_frame_buffer_id, GL_NONE);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, texture.gl_tex_id);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
|
||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, texture.gl_tex_id, 0);
|
||||
|
||||
GLenum status = glCheckNamedFramebufferStatus(*m_frame_buffer_id, GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
std::cout << "Framebuffer error: " << status << std::endl;
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
|
||||
tex_buffer_manager->BindTexture(*m_texture_id, GL_TEXTURE_2D_ARRAY);
|
||||
}
|
||||
void Initialise(uint32_t *texture_id, uint32_t *frame_buffer_id)
|
||||
{
|
||||
m_texture_id = texture_id;
|
||||
m_frame_buffer_id = frame_buffer_id;
|
||||
}
|
||||
};
|
||||
#endif /* HYDRACREATESHADOWFRAMEBUFFER */
|
||||
@@ -10,8 +10,7 @@ class HydraRenderTask : public HydraTask
|
||||
protected:
|
||||
public:
|
||||
virtual void Process() override
|
||||
{
|
||||
GetEngine()->Renderer()->BeginFrame();
|
||||
{
|
||||
GetEngine()->Renderer()->EndFrame();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user