int gs_create(graphics_t *pgraphics, const char *module, struct gs_init_data *data) { int errcode = GS_ERROR_FAIL; graphics_t graphics = bmalloc(sizeof(struct graphics_subsystem)); memset(graphics, 0, sizeof(struct graphics_subsystem)); pthread_mutex_init_value(&graphics->mutex); graphics->module = os_dlopen(module); if (!graphics->module) { errcode = GS_ERROR_MODULENOTFOUND; goto error; } if (!load_graphics_imports(&graphics->exports, graphics->module, module)) goto error; graphics->device = graphics->exports.device_create(data); if (!graphics->device) goto error; if (!graphics_init(graphics)) goto error; *pgraphics = graphics; return GS_SUCCESS; error: gs_destroy(graphics); return errcode; }
static void obs_free_graphics() { struct obs_video *video = &obs->video; size_t i; if (video->graphics) { int cur_texture = video->cur_texture; gs_entercontext(video->graphics); if (video->copy_mapped) stagesurface_unmap(video->copy_surfaces[cur_texture]); for (i = 0; i < NUM_TEXTURES; i++) { stagesurface_destroy(video->copy_surfaces[i]); texture_destroy(video->render_textures[i]); texture_destroy(video->output_textures[i]); video->copy_surfaces[i] = NULL; video->render_textures[i] = NULL; video->output_textures[i] = NULL; } effect_destroy(video->default_effect); video->default_effect = NULL; gs_leavecontext(); gs_destroy(video->graphics); video->graphics = NULL; video->cur_texture = 0; } }
static void obs_free_graphics(void) { struct obs_core_video *video = &obs->video; if (video->graphics) { gs_entercontext(video->graphics); effect_destroy(video->default_effect); effect_destroy(video->solid_effect); effect_destroy(video->conversion_effect); video->default_effect = NULL; gs_leavecontext(); gs_destroy(video->graphics); video->graphics = NULL; } }