Route framebuffer texture copies through GL backend
This commit is contained in:
50
src/util.cpp
50
src/util.cpp
@@ -67,6 +67,27 @@ void bind_opengl_sampler(std::uint32_t unit, std::uint32_t sampler) noexcept
|
||||
glBindSampler(static_cast<GLuint>(unit), static_cast<GLuint>(sampler));
|
||||
}
|
||||
|
||||
void copy_opengl_tex_sub_image_2d(
|
||||
std::uint32_t target,
|
||||
std::int32_t level,
|
||||
std::int32_t destination_x,
|
||||
std::int32_t destination_y,
|
||||
std::int32_t source_x,
|
||||
std::int32_t source_y,
|
||||
std::int32_t width,
|
||||
std::int32_t height) noexcept
|
||||
{
|
||||
glCopyTexSubImage2D(
|
||||
static_cast<GLenum>(target),
|
||||
static_cast<GLint>(level),
|
||||
static_cast<GLint>(destination_x),
|
||||
static_cast<GLint>(destination_y),
|
||||
static_cast<GLint>(source_x),
|
||||
static_cast<GLint>(source_y),
|
||||
static_cast<GLsizei>(width),
|
||||
static_cast<GLsizei>(height));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
@@ -719,6 +740,35 @@ void check_OpenGLError(const char* stmt, const char* fname, int line)
|
||||
}
|
||||
}
|
||||
|
||||
bool copy_framebuffer_to_texture_2d(
|
||||
int destination_x,
|
||||
int destination_y,
|
||||
int source_x,
|
||||
int source_y,
|
||||
int width,
|
||||
int height,
|
||||
int level) noexcept
|
||||
{
|
||||
const auto status = pp::renderer::gl::copy_opengl_framebuffer_to_texture_2d(
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopy {
|
||||
.level = level,
|
||||
.destination_x = destination_x,
|
||||
.destination_y = destination_y,
|
||||
.source_x = source_x,
|
||||
.source_y = source_y,
|
||||
.width = width,
|
||||
.height = height,
|
||||
},
|
||||
pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {
|
||||
.copy_tex_sub_image_2d = copy_opengl_tex_sub_image_2d,
|
||||
});
|
||||
if (!status.ok()) {
|
||||
LOG("OpenGL framebuffer-to-texture copy failed: %s", status.message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t curl_data_handler(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
auto buffer = reinterpret_cast<std::string*>(userp);
|
||||
|
||||
Reference in New Issue
Block a user