提交 89a5bdbc 编写于 作者: J jp9000

Add gs_device_type function

This allows a programatic way of determining the type of graphics module
currently active.
上级 a446dd74
......@@ -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";
......
......@@ -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";
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 ?
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册