From 3019dccf87981e82fc157d440fb1062ff642acb6 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 15 Mar 2016 20:22:03 -0700 Subject: [PATCH] libobs: Add obs_load_effect function Just creates an effect to the target variable only if its current value is null. This will be used for deinterlacing effects to prevent having to compile the shaders unless they're actually being used. --- libobs/obs-internal.h | 2 ++ libobs/obs.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index 40e3403a3..2be6809d2 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -371,6 +371,8 @@ extern struct obs_core *obs; extern void *obs_video_thread(void *param); +extern gs_effect_t *obs_load_effect(gs_effect_t **effect, const char *file); + extern bool audio_callback(void *param, uint64_t start_ts_in, uint64_t end_ts_in, uint64_t *out_ts, uint32_t mixers, struct audio_output_data *mixes); diff --git a/libobs/obs.c b/libobs/obs.c index 966f2d96f..664176313 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -215,6 +215,17 @@ static bool obs_init_textures(struct obs_video_info *ovi) return true; } +gs_effect_t *obs_load_effect(gs_effect_t **effect, const char *file) +{ + if (!*effect) { + char *filename = find_libobs_data_file(file); + *effect = gs_effect_create_from_file(filename, NULL); + bfree(filename); + } + + return *effect; +} + static int obs_init_graphics(struct obs_video_info *ovi) { struct obs_core_video *video = &obs->video;