effect_t create_opaque_effect(void) { effect_t opaque_effect; char *effect_file; char *error_string = NULL; effect_file = obs_find_plugin_file("win-capture/opaque.effect"); if (!effect_file) { blog(LOG_ERROR, "[create_opaque_effect] Could not find " "opaque effect file"); return false; } gs_entercontext(obs_graphics()); opaque_effect = gs_create_effect_from_file(effect_file, &error_string); if (!opaque_effect) { if (error_string) blog(LOG_ERROR, "[create_opaque_effect] Failed to " "create opaque effect:\n%s", error_string); else blog(LOG_ERROR, "[create_opaque_effect] Failed to " "create opaque effect"); } bfree(effect_file); bfree(error_string); gs_leavecontext(); return opaque_effect; }
static void *filter_create(obs_data_t settings, obs_source_t source) { struct test_filter *tf = bzalloc(sizeof(struct test_filter)); char *effect_file; gs_entercontext(obs_graphics()); effect_file = obs_find_plugin_file("test-input/test.effect"); tf->source = source; tf->whatever = gs_create_effect_from_file(effect_file, NULL); bfree(effect_file); if (!tf->whatever) { filter_destroy(tf); return NULL; } gs_leavecontext(); UNUSED_PARAMETER(settings); return tf; }
struct test_filter *test_create(const char *settings, obs_source_t source) { struct test_filter *tf = bmalloc(sizeof(struct test_filter)); char *effect_file; memset(tf, 0, sizeof(struct test_filter)); gs_entercontext(obs_graphics()); effect_file = obs_find_plugin_file("test-input/test.effect"); tf->source = source; tf->whatever = gs_create_effect_from_file(effect_file, NULL); bfree(effect_file); if (!tf->whatever) { test_destroy(tf); return NULL; } tf->texrender = texrender_create(GS_RGBA, GS_ZS_NONE); gs_leavecontext(); return tf; }