Add gs_device_type function

This allows a programatic way of determining the type of graphics module
currently active.
master
jp9000 2014-07-20 16:19:43 -07:00
parent a446dd74af
commit 89a5bdbcf1
7 changed files with 22 additions and 0 deletions

View File

@ -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";

View File

@ -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";

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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 ?

View File

@ -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);