diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 83437336b..256ec6fd7 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -829,6 +829,11 @@ void device_leave_context(gs_device_t *device) UNUSED_PARAMETER(device); } +void *device_get_device_obj(gs_device_t *device) +{ + return (void *)device->device.Get(); +} + gs_swapchain_t *device_swapchain_create(gs_device_t *device, const struct gs_init_data *data) { diff --git a/libobs-opengl/gl-cocoa.m b/libobs-opengl/gl-cocoa.m index 2c65847bd..70d667fbc 100644 --- a/libobs-opengl/gl-cocoa.m +++ b/libobs-opengl/gl-cocoa.m @@ -165,6 +165,11 @@ void device_leave_context(gs_device_t *device) [NSOpenGLContext clearCurrentContext]; } +void *device_get_device_obj(gs_device_t *device) +{ + return device->plat->context; +} + void device_load_swapchain(gs_device_t *device, gs_swapchain_t *swap) { if (device->cur_swap == swap) diff --git a/libobs-opengl/gl-windows.c b/libobs-opengl/gl-windows.c index 389bd9d57..3b2e9cd1b 100644 --- a/libobs-opengl/gl-windows.c +++ b/libobs-opengl/gl-windows.c @@ -542,6 +542,11 @@ void device_leave_context(gs_device_t *device) UNUSED_PARAMETER(device); } +void *device_get_device_obj(gs_device_t *device) +{ + return device->plat->hrc; +} + void device_load_swapchain(gs_device_t *device, gs_swapchain_t *swap) { HDC hdc = device->plat->window.hdc; diff --git a/libobs-opengl/gl-x11.c b/libobs-opengl/gl-x11.c index a85050031..ae35be9a9 100644 --- a/libobs-opengl/gl-x11.c +++ b/libobs-opengl/gl-x11.c @@ -510,6 +510,11 @@ extern void device_leave_context(gs_device_t *device) } } +void *device_get_device_obj(gs_device_t *device) +{ + return device->plat->context; +} + extern void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width, uint32_t *height) { diff --git a/libobs/graphics/device-exports.h b/libobs/graphics/device-exports.h index c1bff7002..1f03a5da6 100644 --- a/libobs/graphics/device-exports.h +++ b/libobs/graphics/device-exports.h @@ -33,6 +33,7 @@ EXPORT int device_create(gs_device_t **device, uint32_t adapter); EXPORT void device_destroy(gs_device_t *device); EXPORT void device_enter_context(gs_device_t *device); EXPORT void device_leave_context(gs_device_t *device); +EXPORT void *device_get_device_obj(gs_device_t *device); EXPORT gs_swapchain_t *device_swapchain_create(gs_device_t *device, const struct gs_init_data *data); EXPORT void device_resize(gs_device_t *device, uint32_t x, uint32_t y); diff --git a/libobs/graphics/graphics-imports.c b/libobs/graphics/graphics-imports.c index 897965cef..10a42b566 100644 --- a/libobs/graphics/graphics-imports.c +++ b/libobs/graphics/graphics-imports.c @@ -50,6 +50,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module, GRAPHICS_IMPORT(device_destroy); GRAPHICS_IMPORT(device_enter_context); GRAPHICS_IMPORT(device_leave_context); + GRAPHICS_IMPORT(device_get_device_obj); GRAPHICS_IMPORT(device_swapchain_create); GRAPHICS_IMPORT(device_resize); GRAPHICS_IMPORT(device_get_size); diff --git a/libobs/graphics/graphics-internal.h b/libobs/graphics/graphics-internal.h index 6b4f42caa..e527e1e61 100644 --- a/libobs/graphics/graphics-internal.h +++ b/libobs/graphics/graphics-internal.h @@ -34,6 +34,7 @@ struct gs_exports { void (*device_destroy)(gs_device_t *device); void (*device_enter_context)(gs_device_t *device); void (*device_leave_context)(gs_device_t *device); + void *(*device_get_device_obj)(gs_device_t *device); gs_swapchain_t *(*device_swapchain_create)( gs_device_t *device, const struct gs_init_data *data); void (*device_resize)(gs_device_t *device, uint32_t x, uint32_t y); diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c index 9955beefd..4324b86b4 100644 --- a/libobs/graphics/graphics.c +++ b/libobs/graphics/graphics.c @@ -288,6 +288,14 @@ graphics_t *gs_get_context(void) return thread_graphics; } +void *gs_get_device_obj(void) +{ + if (!gs_valid("gs_get_device_obj")) + return NULL; + + return thread_graphics->exports.device_get_device_obj(thread_graphics); +} + const char *gs_get_device_name(void) { return gs_valid("gs_get_device_name") diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index 726225852..14245dd4e 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -500,6 +500,7 @@ EXPORT void gs_destroy(graphics_t *graphics); EXPORT void gs_enter_context(graphics_t *graphics); EXPORT void gs_leave_context(void); EXPORT graphics_t *gs_get_context(void); +EXPORT void *gs_get_device_obj(void); EXPORT void gs_matrix_push(void); EXPORT void gs_matrix_pop(void);