From 77b3c3843eaad4cba5f56e59665cd9598157d6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 17 Aug 2015 16:43:56 -0700 Subject: [PATCH] Added HiDPI reset flag. --- examples/common/entry/entry.cpp | 2 ++ include/bgfxdefines.h | 16 +++++++++------- src/glcontext_nsgl.mm | 7 ++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index e8a01197..45cebf1e 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -233,6 +233,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); || setOrToggle(s_reset, "msaa", BGFX_RESET_MSAA_X16, 1, _argc, _argv) || setOrToggle(s_reset, "flush", BGFX_RESET_FLUSH_AFTER_RENDER, 1, _argc, _argv) || setOrToggle(s_reset, "flip", BGFX_RESET_FLIP_AFTER_RENDER, 1, _argc, _argv) + || setOrToggle(s_reset, "hidpi", BGFX_RESET_HIDPI, 1, _argc, _argv) ) { return 0; @@ -297,6 +298,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); { entry::Key::F7, entry::Modifier::None, 1, NULL, "graphics vsync" }, { entry::Key::F8, entry::Modifier::None, 1, NULL, "graphics msaa" }, { entry::Key::F9, entry::Modifier::None, 1, NULL, "graphics flush" }, + { entry::Key::F10, entry::Modifier::None, 1, NULL, "graphics hidpi" }, { entry::Key::Print, entry::Modifier::None, 1, NULL, "graphics screenshot" }, INPUT_BINDING_END diff --git a/include/bgfxdefines.h b/include/bgfxdefines.h index eb985bb7..dbe82f8e 100644 --- a/include/bgfxdefines.h +++ b/include/bgfxdefines.h @@ -338,6 +338,7 @@ #define BGFX_RESET_FLUSH_AFTER_RENDER UINT32_C(0x00002000) //!< Flush rendering after submitting to GPU. #define BGFX_RESET_FLIP_AFTER_RENDER UINT32_C(0x00004000) //!< This flag specifies where flip occurs. Default behavior is that flip occurs before rendering new frame. This flag only has effect when `BGFX_CONFIG_MULTITHREADED=0`. #define BGFX_RESET_SRGB_BACKBUFFER UINT32_C(0x00008000) //!< Enable sRGB backbuffer. +#define BGFX_RESET_HIDPI UINT32_C(0x00010000) //!< Enable HiDPI rendering. /// #define BGFX_CAPS_TEXTURE_COMPARE_LEQUAL UINT64_C(0x0000000000000001) //!< Texture compare less equal mode is supported. @@ -355,15 +356,16 @@ #define BGFX_CAPS_HMD UINT64_C(0x0000000000001000) //!< Head Mounted Display is available. #define BGFX_CAPS_INDEX32 UINT64_C(0x0000000000002000) //!< 32-bit indices are supported. #define BGFX_CAPS_DRAW_INDIRECT UINT64_C(0x0000000000004000) //!< Draw indirect is supported. +#define BGFX_CAPS_HIDPI UINT64_C(0x0000000000008000) //!< HiDPI rendering is supported. /// -#define BGFX_CAPS_FORMAT_TEXTURE_NONE UINT8_C(0x00) //!< -#define BGFX_CAPS_FORMAT_TEXTURE_COLOR UINT8_C(0x01) //!< -#define BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB UINT8_C(0x02) //!< -#define BGFX_CAPS_FORMAT_TEXTURE_EMULATED UINT8_C(0x04) //!< -#define BGFX_CAPS_FORMAT_TEXTURE_VERTEX UINT8_C(0x08) //!< -#define BGFX_CAPS_FORMAT_TEXTURE_IMAGE UINT8_C(0x10) //!< -#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER UINT8_C(0x20) //!< +#define BGFX_CAPS_FORMAT_TEXTURE_NONE UINT8_C(0x00) //!< Texture format is not supported. +#define BGFX_CAPS_FORMAT_TEXTURE_COLOR UINT8_C(0x01) //!< Texture format is supported. +#define BGFX_CAPS_FORMAT_TEXTURE_COLOR_SRGB UINT8_C(0x02) //!< Texture as sRGB format is supported. +#define BGFX_CAPS_FORMAT_TEXTURE_EMULATED UINT8_C(0x04) //!< Texture format is emulated. +#define BGFX_CAPS_FORMAT_TEXTURE_VERTEX UINT8_C(0x08) //!< Texture format can be used from vertex shader. +#define BGFX_CAPS_FORMAT_TEXTURE_IMAGE UINT8_C(0x10) //!< Texture format can be used as image from compute shader. +#define BGFX_CAPS_FORMAT_TEXTURE_FRAMEBUFFER UINT8_C(0x20) //!< Texture format can be used as frame buffer. /// #define BGFX_VIEW_NONE UINT8_C(0x00) //!< diff --git a/src/glcontext_nsgl.mm b/src/glcontext_nsgl.mm index fee4bed2..774e3a92 100644 --- a/src/glcontext_nsgl.mm +++ b/src/glcontext_nsgl.mm @@ -101,7 +101,6 @@ namespace bgfx { namespace gl NSOpenGLView* glView = [[NSOpenGLView alloc] initWithFrame:glViewRect pixelFormat:pixelFormat]; [pixelFormat release]; -// [glView setWantsBestResolutionOpenGLSurface:YES]; [nsWindow setContentView:glView]; NSOpenGLContext* glContext = [glView openGLContext]; @@ -115,6 +114,8 @@ namespace bgfx { namespace gl m_context = glContext; } +// float x = [nsWindow backingScaleFactor]; + import(); } @@ -135,6 +136,10 @@ namespace bgfx { namespace gl { BX_UNUSED(_width, _height); + bool hidpi = !!(_flags&BGFX_RESET_HIDPI); + NSOpenGLView* glView = (NSOpenGLView*)m_view; + [glView setWantsBestResolutionOpenGLSurface:hidpi]; + bool vsync = !!(_flags&BGFX_RESET_VSYNC); GLint interval = vsync ? 1 : 0; NSOpenGLContext* glContext = (NSOpenGLContext*)m_context;