gl_common: reduce some code duplication

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-03-15 20:05:01 +00:00
parent 0eca07d400
commit b3590f934f
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 1 additions and 5 deletions

View File

@ -1304,14 +1304,10 @@ static inline void gl_image_decouple(backend_t *base, struct gl_image *img) {
struct gl_data *gl = (void *)base; struct gl_data *gl = (void *)base;
auto new_tex = ccalloc(1, struct gl_texture); auto new_tex = ccalloc(1, struct gl_texture);
glGenTextures(1, &new_tex->texture); new_tex->texture = gl_new_texture(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, new_tex->texture); glBindTexture(GL_TEXTURE_2D, new_tex->texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, img->inner->width, img->inner->height, 0, glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, img->inner->width, img->inner->height, 0,
GL_BGRA, GL_UNSIGNED_BYTE, NULL); GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
new_tex->y_inverted = true; new_tex->y_inverted = true;
new_tex->height = img->inner->height; new_tex->height = img->inner->height;
new_tex->width = img->inner->width; new_tex->width = img->inner->width;