Move canvas depth renderbuffers into GL backend
This commit is contained in:
@@ -939,6 +939,70 @@ pp::foundation::Status restore_opengl_framebuffer_binding(
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Result<std::uint32_t> allocate_opengl_depth_renderbuffer(
|
||||
std::int32_t width,
|
||||
std::int32_t height,
|
||||
OpenGlDepthRenderbufferAllocationDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.gen_renderbuffers == nullptr
|
||||
|| dispatch.bind_renderbuffer == nullptr
|
||||
|| dispatch.renderbuffer_storage == nullptr) {
|
||||
return pp::foundation::Result<std::uint32_t>::failure(
|
||||
pp::foundation::Status::invalid_argument(
|
||||
"OpenGL depth renderbuffer allocation dispatch callbacks must not be null"));
|
||||
}
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
return pp::foundation::Result<std::uint32_t>::failure(
|
||||
pp::foundation::Status::invalid_argument("OpenGL depth renderbuffer dimensions are invalid"));
|
||||
}
|
||||
|
||||
std::uint32_t renderbuffer_id = 0U;
|
||||
dispatch.gen_renderbuffers(1U, &renderbuffer_id);
|
||||
if (renderbuffer_id == 0U) {
|
||||
return pp::foundation::Result<std::uint32_t>::failure(
|
||||
pp::foundation::Status::out_of_range("OpenGL renderbuffer allocation returned id 0"));
|
||||
}
|
||||
|
||||
dispatch.bind_renderbuffer(renderbuffer_target(), renderbuffer_id);
|
||||
dispatch.renderbuffer_storage(renderbuffer_target(), depth_component24_format(), width, height);
|
||||
dispatch.bind_renderbuffer(renderbuffer_target(), default_framebuffer_id());
|
||||
return pp::foundation::Result<std::uint32_t>::success(renderbuffer_id);
|
||||
}
|
||||
|
||||
pp::foundation::Status delete_opengl_renderbuffer(
|
||||
std::uint32_t renderbuffer_id,
|
||||
OpenGlRenderbufferDeleteDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.delete_renderbuffers == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument("OpenGL renderbuffer delete callback must not be null");
|
||||
}
|
||||
|
||||
if (renderbuffer_id == 0U) {
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
dispatch.delete_renderbuffers(1U, &renderbuffer_id);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status attach_opengl_depth_renderbuffer(
|
||||
std::uint32_t renderbuffer_id,
|
||||
OpenGlDepthRenderbufferAttachmentDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.framebuffer_renderbuffer == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument(
|
||||
"OpenGL depth renderbuffer attachment callback must not be null");
|
||||
}
|
||||
|
||||
dispatch.framebuffer_renderbuffer(
|
||||
framebuffer_target(),
|
||||
framebuffer_depth_attachment(),
|
||||
renderbuffer_target(),
|
||||
renderbuffer_id);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Result<std::uint32_t> create_opengl_sampler(
|
||||
std::span<const OpenGlTextureParameter> parameters,
|
||||
OpenGlSamplerCreateDispatch dispatch) noexcept
|
||||
|
||||
Reference in New Issue
Block a user