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.
This commit is contained in:
jp9000 2016-01-03 15:52:56 -08:00
parent 46feac7f8f
commit bdd7577a1a
2 changed files with 11 additions and 0 deletions

View File

@ -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 {

View File

@ -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);