浏览代码

Add gs_device_name function

This returns the name of the device, "Direct3D 11" or "OpenGL"
respectively.
jp9000 11 年之前
父节点
当前提交
a446dd74af

+ 5 - 0
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";

+ 5 - 0
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";

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

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

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

+ 5 - 0
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 ? 

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