From 72774fd8e127d6d1f1feda63f6711d8fedd869e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Tue, 27 Oct 2015 15:14:48 -0700 Subject: [PATCH] Added resetView. --- include/bgfx/bgfx.h | 8 ++++++++ src/bgfx.cpp | 24 ++++++++++++++---------- src/bgfx_p.h | 11 +++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/bgfx/bgfx.h b/include/bgfx/bgfx.h index 87893862..64cd158c 100644 --- a/include/bgfx/bgfx.h +++ b/include/bgfx/bgfx.h @@ -1688,6 +1688,14 @@ namespace bgfx /// void setViewRemap(uint8_t _id = 0, uint8_t _num = UINT8_MAX, const void* _remap = NULL); + /// Reset all view settings to default. + /// + /// @param[in] _id View id. + /// + /// @attention C99 equivalent is `bgfx_reset_view`. + /// + void resetView(uint8_t _id); + /// Sets debug marker. /// /// @attention C99 equivalent is `bgfx_set_marker`. diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 452cf816..51b52b03 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -1096,17 +1096,9 @@ namespace bgfx m_viewRemap[ii] = uint8_t(ii); } - memset(m_fb, 0xff, sizeof(m_fb) ); - memset(m_clear, 0, sizeof(m_clear) ); - memset(m_rect, 0, sizeof(m_rect) ); - memset(m_scissor, 0, sizeof(m_scissor) ); - memset(m_seq, 0, sizeof(m_seq) ); - memset(m_seqMask, 0, sizeof(m_seqMask) ); - - for (uint32_t ii = 0; ii < BX_COUNTOF(m_rect); ++ii) + for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_VIEWS; ++ii) { - m_rect[ii].m_width = 1; - m_rect[ii].m_height = 1; + resetView(uint8_t(ii) ); } for (uint32_t ii = 0; ii < BX_COUNTOF(m_clearColor); ++ii) @@ -3125,6 +3117,13 @@ again: s_ctx->setViewRemap(_id, _num, _remap); } + void resetView(uint8_t _id) + { + BGFX_CHECK_MAIN_THREAD(); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); + s_ctx->resetView(_id); + } + void setMarker(const char* _marker) { BGFX_CHECK_MAIN_THREAD(); @@ -3997,6 +3996,11 @@ BGFX_C_API void bgfx_set_view_remap(uint8_t _id, uint8_t _num, const void* _rema bgfx::setViewRemap(_id, _num, _remap); } +BGFX_C_API void bgfx_reset_view(uint8_t _id) +{ + bgfx::resetView(_id); +} + BGFX_C_API void bgfx_set_marker(const char* _marker) { bgfx::setMarker(_marker); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 1c5ad935..fe9f89d9 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -3397,6 +3397,17 @@ namespace bgfx } } + BGFX_API_FUNC(void resetView(uint8_t _id) ) + { + setViewRect(_id, 0, 0, 1, 1); + setViewScissor(_id, 0, 0, 0, 0); + setViewClear(_id, BGFX_CLEAR_NONE, 0, 0.0f, 0); + setViewSeq(_id, false); + bgfx::FrameBufferHandle invalid = BGFX_INVALID_HANDLE; + setViewFrameBuffer(_id, invalid); + setViewTransform(_id, NULL, NULL, BGFX_VIEW_NONE, NULL); + } + BGFX_API_FUNC(void setViewRemap(uint8_t _id, uint8_t _num, const void* _remap) ) { const uint32_t num = bx::uint32_min(_id + _num, BGFX_CONFIG_MAX_VIEWS) - _id;