From a446dd74af68605f2b56f0275917d9278d8bc84a Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 20 Jul 2014 15:31:45 -0700 Subject: [PATCH] Add gs_device_name function This returns the name of the device, "Direct3D 11" or "OpenGL" respectively. --- libobs-d3d11/d3d11-subsystem.cpp | 5 +++++ libobs-opengl/gl-subsystem.c | 5 +++++ libobs/graphics/device-exports.h | 1 + libobs/graphics/graphics-imports.c | 1 + libobs/graphics/graphics-internal.h | 1 + libobs/graphics/graphics.c | 5 +++++ libobs/graphics/graphics.h | 2 ++ 7 files changed, 20 insertions(+) diff --git a/libobs-d3d11/d3d11-subsystem.cpp b/libobs-d3d11/d3d11-subsystem.cpp index 1418e3d0b..c0ac9758e 100644 --- a/libobs-d3d11/d3d11-subsystem.cpp +++ b/libobs-d3d11/d3d11-subsystem.cpp @@ -418,6 +418,11 @@ gs_device::gs_device(gs_init_data *data) device_setrendertarget(this, NULL, NULL); } +const char *device_name(void) +{ + return "Direct3D 11"; +} + const char *device_preprocessor_name(void) { return "_D3D11"; diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index 3ef74e34e..cf35a8d62 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -182,6 +182,11 @@ void convert_sampler_info(struct gs_sampler_state *sampler, info->max_anisotropy, sampler->max_anisotropy); } +const char *device_name(void) +{ + return "OpenGL"; +} + const char *device_preprocessor_name(void) { return "_OPENGL"; diff --git a/libobs/graphics/device-exports.h b/libobs/graphics/device-exports.h index 5eb0fb638..3c961876d 100644 --- a/libobs/graphics/device-exports.h +++ b/libobs/graphics/device-exports.h @@ -23,6 +23,7 @@ extern "C" { #endif +EXPORT const char *device_name(void); EXPORT const char *device_preprocessor_name(void); EXPORT device_t device_create(struct gs_init_data *data); EXPORT void device_destroy(device_t device); diff --git a/libobs/graphics/graphics-imports.c b/libobs/graphics/graphics-imports.c index 917761cfa..1215341e8 100644 --- a/libobs/graphics/graphics-imports.c +++ b/libobs/graphics/graphics-imports.c @@ -40,6 +40,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module, { bool success = true; + GRAPHICS_IMPORT(device_name); GRAPHICS_IMPORT(device_preprocessor_name); GRAPHICS_IMPORT(device_create); GRAPHICS_IMPORT(device_destroy); diff --git a/libobs/graphics/graphics-internal.h b/libobs/graphics/graphics-internal.h index 78292390c..758abcb0a 100644 --- a/libobs/graphics/graphics-internal.h +++ b/libobs/graphics/graphics-internal.h @@ -24,6 +24,7 @@ #include "matrix4.h" struct gs_exports { + const char *(*device_name)(void); const char *(*device_preprocessor_name)(void); device_t (*device_create)(struct gs_init_data *data); void (*device_destroy)(device_t device); diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c index b2a8f51b8..13b54289e 100644 --- a/libobs/graphics/graphics.c +++ b/libobs/graphics/graphics.c @@ -215,6 +215,11 @@ graphics_t gs_getcontext(void) return thread_graphics; } +const char *gs_device_name(void) +{ + return thread_graphics ? thread_graphics->exports.device_name() : NULL; +} + static inline struct matrix4 *top_matrix(graphics_t graphics) { return graphics ? diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h index 03f5571d9..640e69373 100644 --- a/libobs/graphics/graphics.h +++ b/libobs/graphics/graphics.h @@ -416,6 +416,8 @@ struct gs_init_data { uint32_t adapter; }; +EXPORT const char *gs_device_name(void); + EXPORT int gs_create(graphics_t *graphics, const char *module, struct gs_init_data *data); EXPORT void gs_destroy(graphics_t graphics);