diff options
Diffstat (limited to '3rdparty/bgfx/examples/30-picking/picking.cpp')
-rw-r--r-- | 3rdparty/bgfx/examples/30-picking/picking.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/3rdparty/bgfx/examples/30-picking/picking.cpp b/3rdparty/bgfx/examples/30-picking/picking.cpp index 7847e1ba406..9a5c36d8fd8 100644 --- a/3rdparty/bgfx/examples/30-picking/picking.cpp +++ b/3rdparty/bgfx/examples/30-picking/picking.cpp @@ -1,6 +1,6 @@ /* * Copyright 2016 Joseph Cherlin. All rights reserved. - * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause + * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE */ #include "common.h" @@ -21,8 +21,8 @@ namespace class ExamplePicking : public entry::AppI { public: - ExamplePicking(const char* _name, const char* _description) - : entry::AppI(_name, _description) + ExamplePicking(const char* _name, const char* _description, const char* _url) + : entry::AppI(_name, _description, _url) { } @@ -38,6 +38,9 @@ public: bgfx::Init init; init.type = args.m_type; init.vendorId = args.m_pciId; + init.platformData.nwh = entry::getNativeWindowHandle(entry::kDefaultWindowHandle); + init.platformData.ndt = entry::getNativeDisplayHandle(); + init.platformData.type = entry::getNativeWindowHandleType(entry::kDefaultWindowHandle); init.resolution.width = m_width; init.resolution.height = m_height; init.resolution.reset = m_reset; @@ -54,7 +57,7 @@ public: , 0 ); - // ID buffer clears to black, which represnts clicking on nothing (background) + // ID buffer clears to black, which represents clicking on nothing (background) bgfx::setViewClear(RENDER_PASS_ID , BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH , 0x000000ff @@ -124,7 +127,7 @@ public: | BGFX_SAMPLER_U_CLAMP | BGFX_SAMPLER_V_CLAMP ); - m_pickingRTDepth = bgfx::createTexture2D(ID_DIM, ID_DIM, false, 1, bgfx::TextureFormat::D24S8, 0 + m_pickingRTDepth = bgfx::createTexture2D(ID_DIM, ID_DIM, false, 1, bgfx::TextureFormat::D32F, 0 | BGFX_TEXTURE_RT | BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT @@ -268,17 +271,12 @@ public: float mouseXNDC = ( m_mouseState.m_mx / (float)m_width ) * 2.0f - 1.0f; float mouseYNDC = ((m_height - m_mouseState.m_my) / (float)m_height) * 2.0f - 1.0f; - float pickEye[3]; - float mousePosNDC[3] = { mouseXNDC, mouseYNDC, 0.0f }; - bx::vec3MulMtxH(pickEye, mousePosNDC, invViewProj); - - float pickAt[3]; - float mousePosNDCEnd[3] = { mouseXNDC, mouseYNDC, 1.0f }; - bx::vec3MulMtxH(pickAt, mousePosNDCEnd, invViewProj); + const bx::Vec3 pickEye = bx::mulH({ mouseXNDC, mouseYNDC, 0.0f }, invViewProj); + const bx::Vec3 pickAt = bx::mulH({ mouseXNDC, mouseYNDC, 1.0f }, invViewProj); // Look at our unprojected point float pickView[16]; - bx::mtxLookAt(pickView, bx::load(pickEye), bx::load(pickAt) ); + bx::mtxLookAt(pickView, pickEye, pickAt); // Tight FOV is best for picking float pickProj[16]; @@ -447,4 +445,9 @@ public: } // namespace -ENTRY_IMPLEMENT_MAIN(ExamplePicking, "30-picking", "Mouse picking via GPU texture readback."); +ENTRY_IMPLEMENT_MAIN( + ExamplePicking + , "30-picking" + , "Mouse picking via GPU texture readback." + , "https://bkaradzic.github.io/bgfx/examples.html#picking" + ); |