[LIBNX] Native 1080p support

This commit is contained in:
M4xw 2019-01-01 00:25:54 +01:00
parent bb5cd1dfeb
commit a2eaa6a19d
1 changed files with 32 additions and 6 deletions

View File

@ -46,10 +46,20 @@ void switch_ctx_destroy(void *data)
static void switch_ctx_get_video_size(void *data, static void switch_ctx_get_video_size(void *data,
unsigned *width, unsigned *height) unsigned *width, unsigned *height)
{ {
switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data; switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data;
*width = 1280; switch (appletGetOperationMode())
*height = 720; {
default:
case AppletOperationMode_Handheld:
*width = 1280;
*height = 720;
break;
case AppletOperationMode_Docked:
*width = 1920;
*height = 1080;
break;
}
} }
static void *switch_ctx_init(video_frame_info_t *video_info, void *video_driver) static void *switch_ctx_init(video_frame_info_t *video_info, void *video_driver)
@ -86,6 +96,10 @@ static void *switch_ctx_init(video_frame_info_t *video_info, void *video_driver)
setenv("NV50_PROG_CHIPSET", "0x120", 1); setenv("NV50_PROG_CHIPSET", "0x120", 1);
#endif #endif
// Needs to be here
gfxInitResolutionDefault(); // 1080p
gfxConfigureResolution(1920, 1080);
#ifdef HAVE_EGL #ifdef HAVE_EGL
if (!egl_init_context(&ctx_nx->egl, EGL_NONE, EGL_DEFAULT_DISPLAY, if (!egl_init_context(&ctx_nx->egl, EGL_NONE, EGL_DEFAULT_DISPLAY,
&major, &minor, &n, attribs, NULL)) &major, &minor, &n, attribs, NULL))
@ -114,7 +128,18 @@ static void switch_ctx_check_window(void *data, bool *quit,
{ {
*width = new_width; *width = new_width;
*height = new_height; *height = new_height;
switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data;
ctx_nx->width = *width;
ctx_nx->height = *height;
ctx_nx->native_window.width = ctx_nx->width;
ctx_nx->native_window.height = ctx_nx->height;
ctx_nx->resize = true;
*resize = true; *resize = true;
printf("[NXGL]: Resizing to %dx%d\n", *width, *height);
gfxConfigureCrop(0, 1080 - ctx_nx->height, ctx_nx->width, 1080);
} }
*quit = (bool)false; *quit = (bool)false;
@ -133,8 +158,7 @@ static bool switch_ctx_set_video_mode(void *data,
switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data; switch_ctx_data_t *ctx_nx = (switch_ctx_data_t *)data;
ctx_nx->width = 1280; switch_ctx_get_video_size(data, &ctx_nx->width, &ctx_nx->height);
ctx_nx->height = 720;
ctx_nx->native_window.width = ctx_nx->width; ctx_nx->native_window.width = ctx_nx->width;
ctx_nx->native_window.height = ctx_nx->height; ctx_nx->native_window.height = ctx_nx->height;
@ -154,10 +178,12 @@ static bool switch_ctx_set_video_mode(void *data,
goto error; goto error;
#endif #endif
gfxConfigureCrop(0, 1080 - ctx_nx->height, ctx_nx->width, 1080);
return true; return true;
error: error:
printf("[ctx_nx]: EGL error: %d.\n", eglGetError()); printf("[NXGL]: EGL error: %d.\n", eglGetError());
switch_ctx_destroy(data); switch_ctx_destroy(data);
return false; return false;