From 657235129859c72c9ef919e4e001bd2c1878a5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 16 Jun 2017 18:46:21 -0700 Subject: [PATCH] Cleanup. --- examples/07-callback/callback.cpp | 74 +++++++++++++++---------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/examples/07-callback/callback.cpp b/examples/07-callback/callback.cpp index fed014607..5653a391a 100644 --- a/examples/07-callback/callback.cpp +++ b/examples/07-callback/callback.cpp @@ -315,13 +315,13 @@ class ExampleCallback : public entry::AppI void init(int _argc, char** _argv) BX_OVERRIDE { Args args(_argc, _argv); - + m_width = 1280; m_height = 720; - + // Enumerate supported backend renderers. m_numRenderers = bgfx::getSupportedRenderers(BX_COUNTOF(m_renderers), m_renderers); - + bgfx::init(bgfx::RendererType::Count == args.m_type ? m_renderers[bx::getHPCounter() % m_numRenderers] /* randomize renderer */ : args.m_type @@ -331,13 +331,13 @@ class ExampleCallback : public entry::AppI , &m_allocator // custom allocator ); bgfx::reset(m_width, m_height, BGFX_RESET_CAPTURE|BGFX_RESET_MSAA_X16); - + // Enable debug text. bgfx::setDebug(BGFX_DEBUG_TEXT); - + // Set view 0 default viewport. bgfx::setViewRect(0, 0, 0, 1280, 720); - + // Set view 0 clear state. bgfx::setViewClear(0 , BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH @@ -345,22 +345,22 @@ class ExampleCallback : public entry::AppI , 1.0f , 0 ); - + // Create vertex stream declaration. PosColorVertex::init(); - + // Create static vertex buffer. m_vbh = bgfx::createVertexBuffer( bgfx::makeRef(s_cubeVertices, sizeof(s_cubeVertices) ) , PosColorVertex::ms_decl ); - + // Create static index buffer. m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) ); - + // Create program from shaders. m_program = loadProgram("vs_callback", "fs_callback"); - + m_time = 0.0f; m_frame = 0; } @@ -371,43 +371,43 @@ class ExampleCallback : public entry::AppI bgfx::destroyIndexBuffer(m_ibh); bgfx::destroyVertexBuffer(m_vbh); bgfx::destroyProgram(m_program); - + // Shutdown bgfx. bgfx::shutdown(); - + m_allocator.dumpStats(); - + return 0; } - + bool update() BX_OVERRIDE { - - + + // 5 second 60Hz video if ( m_frame < 300) { ++m_frame; const bgfx::RendererType::Enum rendererType = bgfx::getRendererType(); - + // This dummy draw call is here to make sure that view 0 is cleared // if no other draw calls are submitted to view 0. bgfx::touch(0); - + int64_t now = bx::getHPCounter(); static int64_t last = now; const int64_t frameTime = now - last; last = now; const double freq = double(bx::getHPFrequency() ); const double toMs = 1000.0/freq; - + // Use debug font to print information about this example. bgfx::dbgTextClear(); bgfx::dbgTextPrintf( 0, 1, 0x4f, "bgfx/examples/07-callback"); bgfx::dbgTextPrintf( 0, 2, 0x6f, "Description: Implementing application specific callbacks for taking screen shots,"); bgfx::dbgTextPrintf(13, 3, 0x6f, "caching OpenGL binary shaders, and video capture."); bgfx::dbgTextPrintf( 0, 4, 0x0f, "Frame: % 7.3f[ms]", double(frameTime)*toMs); - + bgfx::dbgTextPrintf( 2, 6, 0x0e, "Supported renderers:"); for (uint8_t ii = 0; ii < m_numRenderers; ++ii) { @@ -416,20 +416,20 @@ class ExampleCallback : public entry::AppI , bgfx::getRendererName(m_renderers[ii]) ); } - + float at[3] = { 0.0f, 0.0f, 0.0f }; float eye[3] = { 0.0f, 0.0f, -35.0f }; - + float view[16]; float proj[16]; bx::mtxLookAt(view, eye, at); bx::mtxProj(proj, 60.0f, float(m_width)/float(m_height), 0.1f, 100.0f, bgfx::getCaps()->homogeneousDepth); - + // Set view and projection matrix for view 0. bgfx::setViewTransform(0, view, proj); - + m_time += 1.0f/60.0f; - + // Submit 11x11 cubes. for (uint32_t yy = 0; yy < 11; ++yy) { @@ -440,48 +440,48 @@ class ExampleCallback : public entry::AppI mtx[12] = -15.0f + float(xx)*3.0f; mtx[13] = -15.0f + float(yy)*3.0f; mtx[14] = 0.0f; - + // Set model matrix for rendering. bgfx::setTransform(mtx); - + // Set vertex and index buffer. bgfx::setVertexBuffer(0, m_vbh); bgfx::setIndexBuffer(m_ibh); - + // Set render states. bgfx::setState(BGFX_STATE_DEFAULT); - + // Submit primitive for rendering to view 0. bgfx::submit(0, m_program); } } - + // Take screen shot at frame 150. if (150 == m_frame) { bgfx::FrameBufferHandle fbh = BGFX_INVALID_HANDLE; bgfx::requestScreenShot(fbh, "temp/frame150"); } - + // Advance to next frame. Rendering thread will be kicked to // process submitted rendering primitives. bgfx::frame(); - + return true; } - + return false; } BgfxCallback m_callback; BgfxAllocator m_allocator; - + uint32_t m_width; uint32_t m_height; - + bgfx::RendererType::Enum m_renderers[bgfx::RendererType::Count]; uint8_t m_numRenderers; - + bgfx::VertexBufferHandle m_vbh; bgfx::IndexBufferHandle m_ibh; bgfx::ProgramHandle m_program;