diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-02-08 19:30:26 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-02-08 19:30:26 +0100 |
commit | 348ab7040349858a2b9fa93390bf96011f12687f (patch) | |
tree | 908c9c429f261d6bc20643ebbb15707c84ab8033 /src/capture/xcomposite_cuda.c | |
parent | d1c49f35a5cca15ee17939c7f2a87224f494c5b3 (diff) |
Window capture: move window to center of video (if possible)
Diffstat (limited to 'src/capture/xcomposite_cuda.c')
-rw-r--r-- | src/capture/xcomposite_cuda.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/capture/xcomposite_cuda.c b/src/capture/xcomposite_cuda.c index 58af0be..079f5e3 100644 --- a/src/capture/xcomposite_cuda.c +++ b/src/capture/xcomposite_cuda.c @@ -429,10 +429,14 @@ static int gsr_capture_xcomposite_cuda_capture(gsr_capture *cap, AVFrame *frame) if(cap_xcomp->window_texture.texture_id != 0) { while(cap_xcomp->params.egl->glGetError()) {} + + const int target_x = max_int(0, frame->width / 2 - cap_xcomp->texture_size.x / 2); + const int target_y = max_int(0, frame->height / 2 - cap_xcomp->texture_size.y / 2); + /* TODO: Remove this copy, which is only possible by using nvenc directly and encoding window_pixmap.target_texture_id */ cap_xcomp->params.egl->glCopyImageSubData( window_texture_get_opengl_texture_id(&cap_xcomp->window_texture), GL_TEXTURE_2D, 0, source_pos.x, source_pos.y, 0, - cap_xcomp->target_texture_id, GL_TEXTURE_2D, 0, 0, 0, 0, + cap_xcomp->target_texture_id, GL_TEXTURE_2D, 0, target_x, target_y, 0, source_size.x, source_size.y, 1); unsigned int err = cap_xcomp->params.egl->glGetError(); if(err != 0) { |