From bdd7577a1a91f661a253bcd1d1679fb0a63c0e09 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 3 Jan 2016 15:52:56 -0800 Subject: [PATCH] libobs: Always have a transparent blank texture available Allows transitions to be able to return a blank texture to transitions if a transition is transitioning from/to a NULL source. --- libobs/obs-internal.h | 2 ++ libobs/obs.c | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index 66fa8ede7..33e3a96cf 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -257,6 +257,8 @@ struct obs_core_video { uint32_t base_height; float color_matrix[16]; enum obs_scale_type scale_type; + + gs_texture_t *transparent_texture; }; struct obs_core_audio { diff --git a/libobs/obs.c b/libobs/obs.c index 0257f73e8..6e16e9998 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -218,6 +218,8 @@ static bool obs_init_textures(struct obs_video_info *ovi) static int obs_init_graphics(struct obs_video_info *ovi) { struct obs_core_video *video = &obs->video; + uint8_t transparent_tex_data[2*2*4] = {0}; + const uint8_t *transparent_tex = transparent_tex_data; bool success = true; int errorcode; @@ -278,6 +280,9 @@ static int obs_init_graphics(struct obs_video_info *ovi) NULL); bfree(filename); + obs->video.transparent_texture = gs_texture_create(2, 2, GS_RGBA, 1, + &transparent_tex, 0); + if (!video->default_effect) success = false; if (gs_get_device_type() == GS_DEVICE_OPENGL) { @@ -290,6 +295,8 @@ static int obs_init_graphics(struct obs_video_info *ovi) success = false; if (!video->conversion_effect) success = false; + if (!video->transparent_texture) + success = false; gs_leave_context(); return success ? OBS_VIDEO_SUCCESS : OBS_VIDEO_FAIL; @@ -432,6 +439,8 @@ static void obs_free_graphics(void) if (video->graphics) { gs_enter_context(video->graphics); + gs_texture_destroy(video->transparent_texture); + gs_effect_destroy(video->default_effect); gs_effect_destroy(video->default_rect_effect); gs_effect_destroy(video->opaque_effect);