Procházet zdrojové kódy

Add gs_device_type function

This allows a programatic way of determining the type of graphics module
currently active.
jp9000 před 11 roky
rodič
revize
89a5bdbcf1

+ 5 - 0
libobs-d3d11/d3d11-subsystem.cpp

@@ -423,6 +423,11 @@ const char *device_name(void)
 	return "Direct3D 11";
 }
 
+int device_type(void)
+{
+	return GS_DEVICE_DIRECT3D_11;
+}
+
 const char *device_preprocessor_name(void)
 {
 	return "_D3D11";

+ 5 - 0
libobs-opengl/gl-subsystem.c

@@ -187,6 +187,11 @@ const char *device_name(void)
 	return "OpenGL";
 }
 
+int device_type(void)
+{
+	return GS_DEVICE_OPENGL;
+}
+
 const char *device_preprocessor_name(void)
 {
 	return "_OPENGL";

+ 1 - 0
libobs/graphics/device-exports.h

@@ -24,6 +24,7 @@ extern "C" {
 #endif
 
 EXPORT const char *device_name(void);
+EXPORT int device_type(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

@@ -41,6 +41,7 @@ bool load_graphics_imports(struct gs_exports *exports, void *module,
 	bool success = true;
 
 	GRAPHICS_IMPORT(device_name);
+	GRAPHICS_IMPORT(device_type);
 	GRAPHICS_IMPORT(device_preprocessor_name);
 	GRAPHICS_IMPORT(device_create);
 	GRAPHICS_IMPORT(device_destroy);

+ 1 - 0
libobs/graphics/graphics-internal.h

@@ -25,6 +25,7 @@
 
 struct gs_exports {
 	const char *(*device_name)(void);
+	int (*device_type)(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

@@ -220,6 +220,11 @@ const char *gs_device_name(void)
 	return thread_graphics ? thread_graphics->exports.device_name() : NULL;
 }
 
+int gs_device_type(void)
+{
+	return thread_graphics ? thread_graphics->exports.device_type() : -1;
+}
+
 static inline struct matrix4 *top_matrix(graphics_t graphics)
 {
 	return graphics ? 

+ 4 - 0
libobs/graphics/graphics.h

@@ -416,7 +416,11 @@ struct gs_init_data {
 	uint32_t                adapter;
 };
 
+#define GS_DEVICE_OPENGL      1
+#define GS_DEVICE_DIRECT3D_11 2
+
 EXPORT const char *gs_device_name(void);
+EXPORT int gs_device_type(void);
 
 EXPORT int gs_create(graphics_t *graphics, const char *module,
 		struct gs_init_data *data);