libobs-opengl: Use gl helpers in create_dmabuf_image

This replaces direct OpenGL calls to error handling helpers. Previously
this would cause errors to be misattributed to the next OpenGL functions
called.

Fixes DMA-BUF importing returning a texture on failure on KDE+NVIDIA.
This commit is contained in:
Kurt Kartaltepe 2022-04-10 14:28:58 -07:00 committed by Georges Basile Stavracas Neto
parent ebc291956c
commit f695b14edc

View file

@ -199,17 +199,23 @@ gl_egl_create_dmabuf_image(EGLDisplay egl_display, unsigned int width,
return NULL;
}
texture = gs_texture_create(width, height, color_format, 1, NULL,
GS_DYNAMIC);
if ((texture = gs_texture_create(width, height, color_format, 1, NULL,
GS_DYNAMIC)) == NULL) {
return NULL;
}
const GLuint gltex = *(GLuint *)gs_texture_get_obj(texture);
glBindTexture(GL_TEXTURE_2D, gltex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl_bind_texture(GL_TEXTURE_2D, gltex);
gl_tex_param_i(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
gl_tex_param_i(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image);
if (!gl_success("glEGLImageTargetTexture2DOES")) {
gs_texture_destroy(texture);
texture = NULL;
}
glBindTexture(GL_TEXTURE_2D, 0);
gl_bind_texture(GL_TEXTURE_2D, 0);
eglDestroyImage(egl_display, egl_image);
return texture;