mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-26 03:24:36 +00:00
(Windows) Implement get_metrics for D3D and WGL context drivers
This commit is contained in:
parent
88c300cb58
commit
5e4647994b
@ -492,6 +492,42 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval)
|
||||
#endif
|
||||
}
|
||||
|
||||
static bool gfx_ctx_d3d_get_metrics(void *data,
|
||||
enum display_metric_types type, float *value)
|
||||
{
|
||||
#ifdef _XBOX
|
||||
return false;
|
||||
#else
|
||||
HDC monitor = GetDC(NULL);
|
||||
int pixels_x = GetDeviceCaps(monitor, HORZRES);
|
||||
int pixels_y = GetDeviceCaps(monitor, VERTRES);
|
||||
int physical_width = GetDeviceCaps(monitor, HORZSIZE);
|
||||
int physical_height = GetDeviceCaps(monitor, VERTSIZE);
|
||||
|
||||
ReleaseDC(NULL, monitor);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DISPLAY_METRIC_MM_WIDTH:
|
||||
*value = physical_width;
|
||||
break;
|
||||
case DISPLAY_METRIC_MM_HEIGHT:
|
||||
*value = physical_height;
|
||||
break;
|
||||
case DISPLAY_METRIC_DPI:
|
||||
/* 25.4 mm in an inch. */
|
||||
*value = 254 * pixels_x / physical_width / 10;
|
||||
break;
|
||||
case DISPLAY_METRIC_NONE:
|
||||
default:
|
||||
*value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
const gfx_ctx_driver_t gfx_ctx_d3d = {
|
||||
gfx_ctx_d3d_init,
|
||||
gfx_ctx_d3d_destroy,
|
||||
@ -502,7 +538,7 @@ const gfx_ctx_driver_t gfx_ctx_d3d = {
|
||||
NULL, /* get_video_output_size */
|
||||
NULL, /* get_video_output_prev */
|
||||
NULL, /* get_video_output_next */
|
||||
NULL, /* get_metrics */
|
||||
gfx_ctx_d3d_get_metrics,
|
||||
NULL,
|
||||
gfx_ctx_d3d_update_title,
|
||||
gfx_ctx_d3d_check_window,
|
||||
|
@ -664,6 +664,39 @@ static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
||||
return (gfx_ctx_proc_t)GetProcAddress(dll_handle, symbol);
|
||||
}
|
||||
|
||||
static bool gfx_ctx_wgl_get_metrics(void *data,
|
||||
enum display_metric_types type, float *value)
|
||||
{
|
||||
bool ret = true;
|
||||
HDC monitor = GetDC(NULL);
|
||||
int pixels_x = GetDeviceCaps(monitor, HORZRES);
|
||||
int pixels_y = GetDeviceCaps(monitor, VERTRES);
|
||||
int physical_width = GetDeviceCaps(monitor, HORZSIZE);
|
||||
int physical_height = GetDeviceCaps(monitor, VERTSIZE);
|
||||
|
||||
ReleaseDC(NULL, monitor);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DISPLAY_METRIC_MM_WIDTH:
|
||||
*value = physical_width;
|
||||
break;
|
||||
case DISPLAY_METRIC_MM_HEIGHT:
|
||||
*value = physical_height;
|
||||
break;
|
||||
case DISPLAY_METRIC_DPI:
|
||||
/* 25.4 mm in an inch. */
|
||||
*value = 254 * pixels_x / physical_width / 10;
|
||||
break;
|
||||
case DISPLAY_METRIC_NONE:
|
||||
default:
|
||||
*value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool gfx_ctx_wgl_bind_api(void *data,
|
||||
enum gfx_ctx_api api, unsigned major, unsigned minor)
|
||||
{
|
||||
@ -699,7 +732,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = {
|
||||
NULL, /* get_video_output_size */
|
||||
NULL, /* get_video_output_prev */
|
||||
NULL, /* get_video_output_next */
|
||||
NULL, /* get_metrics */
|
||||
gfx_ctx_wgl_get_metrics,
|
||||
NULL,
|
||||
gfx_ctx_wgl_update_window_title,
|
||||
gfx_ctx_wgl_check_window,
|
||||
|
Loading…
x
Reference in New Issue
Block a user