Skip to content

Commit 57230b0

Browse files
authored
fix: incorrect scaling when stretched and latent bug in VBO case (#86)
Co-authored-by: sandwich <dskvr@users.noreply.github.com>
1 parent f248ccd commit 57230b0

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

src/renderer/gles2.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,14 @@ static void compute_fit_params(int vw, int vh, int tw, int th, int fit_mode,
402402
if (scale <= 0.0f) scale = 1.0f;
403403

404404
if (fit_mode == 0) {
405-
/* STRETCH: defaults suffice */
405+
/* STRETCH: fill viewport. If scale != 1.0, zoom by sampling
406+
* a centered 1/scale UV window. */
407+
if (scale != 1.0f) {
408+
float inv = 1.0f / scale;
409+
float margin = (1.0f - inv) * 0.5f;
410+
*u0 = margin; *v0 = margin;
411+
*u1 = 1.0f - margin; *v1 = 1.0f - margin;
412+
}
406413
return;
407414
}
408415

@@ -930,10 +937,7 @@ static void gles2_draw_layer_internal(const texture_t *texture, float x, float y
930937
GLuint vbo = 0;
931938
if (persist_vbo && *persist_vbo && g_gles2_data->vbo) {
932939
glBindBuffer(GL_ARRAY_BUFFER, g_gles2_data->vbo);
933-
/* If using uniform-offset or separable blur, keep default texcoords; otherwise update texcoords */
934-
if (!uniform_offset_mode && !use_sep_blur) {
935-
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
936-
}
940+
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
937941
} else {
938942
glGenBuffers(1, &vbo);
939943
glBindBuffer(GL_ARRAY_BUFFER, vbo);

0 commit comments

Comments
 (0)