Shadow buffer
This commit is contained in:
@@ -22,30 +22,6 @@ void HydraBufferManager::Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
// HydraID HydraBufferManager::CreateGPUBuffer(std::string buffer_name,
|
||||
// uint32_t buffer_size_bytes,
|
||||
// uint32_t binding,
|
||||
// HYDRA_BUFFER_TYPE buffer_type)
|
||||
// {
|
||||
// HydraID buffer_id = _GetBufferID();
|
||||
// HydraBuffer buffer = {};
|
||||
// buffer.buffer_id = buffer_id;
|
||||
// buffer.size_bytes = buffer_size_bytes;
|
||||
// buffer.buffer_name = buffer_name;
|
||||
// buffer.buffer_type = buffer_type;
|
||||
// uint32_t gl_buffer_type = _DecodeBufferType(buffer_type);
|
||||
// //Create the buffer
|
||||
// glGenBuffers(1, &buffer.gpu_buffer_id);
|
||||
// glBindBuffer(gl_buffer_type, buffer.gpu_buffer_id);
|
||||
// //Allocate storage
|
||||
// glBufferData(gl_buffer_type, buffer.size_bytes, NULL, GL_DYNAMIC_DRAW);
|
||||
// glBindBufferBase(gl_buffer_type, binding, buffer.gpu_buffer_id);
|
||||
// glBindBuffer(gl_buffer_type, 0);
|
||||
// m_buffers[buffer_id] = buffer;
|
||||
// return buffer_id;
|
||||
|
||||
// }
|
||||
|
||||
HydraID HydraBufferManager::CreateGPUBuffer(std::string buffer_name,
|
||||
uint32_t buffer_size_bytes,
|
||||
uint32_t binding,
|
||||
|
||||
@@ -57,7 +57,7 @@ HydraID HydraTextureBufferManager::LoadTexture(std::string texture_filename)
|
||||
HydraID create_tex_id = scheduler->CreateTask<HydraCreateTextureTask>(HydraThreadAffinity::Render);
|
||||
HydraCreateTextureTask *create_tex_task = static_cast<HydraCreateTextureTask *>(scheduler->GetTask(create_tex_id));
|
||||
HydraID tex_id = INVALID_HYDRA_ID;
|
||||
create_tex_task->Initialise(texture_filename,
|
||||
create_tex_task->Initialise(texture_filename,
|
||||
width,
|
||||
height,
|
||||
GL_RGBA8,
|
||||
@@ -107,7 +107,45 @@ HydraID HydraTextureBufferManager::_GetTextureID()
|
||||
return id;
|
||||
}
|
||||
|
||||
HydraID HydraTextureBufferManager::CreateTexture(std::string texture_name,
|
||||
HydraID HydraTextureBufferManager::CreateTextureArray(std::string texture_name,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t internal_format,
|
||||
uint32_t min_filter,
|
||||
uint32_t mag_filter,
|
||||
uint32_t levels
|
||||
)
|
||||
{
|
||||
uint32_t gl_tex_id = 0;
|
||||
glCreateTextures(GL_TEXTURE_2D_ARRAY, 1, &gl_tex_id);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, gl_tex_id);
|
||||
|
||||
|
||||
glTextureStorage3D(gl_tex_id, 1, internal_format, width, height, levels);
|
||||
|
||||
|
||||
glTextureParameteri(gl_tex_id, GL_TEXTURE_MIN_FILTER, min_filter);
|
||||
glTextureParameteri(gl_tex_id, GL_TEXTURE_MAG_FILTER, mag_filter);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
|
||||
HydraTextureBuffer texture_buffer = {};
|
||||
HydraID texture_id = _GetTextureID();
|
||||
texture_buffer.texture_id = texture_id;
|
||||
texture_buffer.format = 0;
|
||||
texture_buffer.internal_format = internal_format;
|
||||
texture_buffer.width = width;
|
||||
texture_buffer.height = height;
|
||||
texture_buffer.gl_tex_id = gl_tex_id;
|
||||
texture_buffer.mag_filter = mag_filter;
|
||||
texture_buffer.min_filter = min_filter;
|
||||
|
||||
m_textures[texture_id] = texture_buffer;
|
||||
m_texture_lookup.insert(std::pair<std::string, HydraID>(texture_name, texture_id));
|
||||
|
||||
return texture_id;
|
||||
}
|
||||
|
||||
HydraID HydraTextureBufferManager::CreateTexture(std::string texture_name,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t internal_format,
|
||||
@@ -162,7 +200,7 @@ HydraID HydraTextureBufferManager::CreateTexture(std::string texture_name,
|
||||
return texture_id;
|
||||
}
|
||||
|
||||
void HydraTextureBufferManager::BindTexture(HydraID texture_id)
|
||||
void HydraTextureBufferManager::BindTexture(HydraID texture_id, uint32_t target)
|
||||
{
|
||||
|
||||
if (texture_id >= MAX_TEXTURES)
|
||||
@@ -170,7 +208,7 @@ void HydraTextureBufferManager::BindTexture(HydraID texture_id)
|
||||
return;
|
||||
}
|
||||
HydraTextureBuffer texture = m_textures[texture_id];
|
||||
glBindTexture(GL_TEXTURE_2D, texture.gl_tex_id);
|
||||
glBindTexture(target, texture.gl_tex_id);
|
||||
glTextureParameteri(texture.gl_tex_id, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTextureParameteri(texture.gl_tex_id, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTextureParameteri(texture.gl_tex_id, GL_TEXTURE_MIN_FILTER, texture.min_filter);
|
||||
|
||||
@@ -18,10 +18,19 @@ class HydraTextureBufferManager : public HydraObject
|
||||
public:
|
||||
void Intialise();
|
||||
void Shutdown();
|
||||
HydraID CreateTexture(std::string texture_name, uint32_t width, uint32_t height, uint32_t internal_format,
|
||||
HydraID CreateTexture(std::string texture_name,
|
||||
uint32_t width, uint32_t height, uint32_t internal_format,
|
||||
uint32_t min_filter, uint32_t mag_filter, uint32_t levels,
|
||||
uint32_t format = GL_RGBA, uint32_t data_type = GL_UNSIGNED_BYTE, uint32_t mip_levels = 0, void* data = nullptr);
|
||||
void BindTexture(HydraID texture_id);
|
||||
uint32_t format = GL_RGBA, uint32_t data_type = GL_UNSIGNED_BYTE, uint32_t mip_levels = 0, void* data = nullptr);
|
||||
|
||||
HydraID CreateTextureArray(std::string texture_name,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t internal_format,
|
||||
uint32_t min_filter,
|
||||
uint32_t mag_filter,
|
||||
uint32_t levels);
|
||||
void BindTexture(HydraID texture_id, uint32_t target);
|
||||
void UnbindTexture(HydraID texture_id);
|
||||
void DeleteTexture(HydraID texture_id);
|
||||
HydraID LoadTexture(std::string texture_filename);
|
||||
|
||||
Reference in New Issue
Block a user