Browse Source

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.
jp9000 9 years ago
parent
commit
3019dccf87
2 changed files with 13 additions and 0 deletions
  1. 2 0
      libobs/obs-internal.h
  2. 11 0
      libobs/obs.c

+ 2 - 0
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);

+ 11 - 0
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;