Add gs_device_name function

This returns the name of the device, "Direct3D 11" or "OpenGL"
respectively.
master
jp9000 2014-07-20 15:31:45 -07:00
parent eeb6fc6e9c
commit a446dd74af
7 changed files with 20 additions and 0 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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