Бранимир Караџић 5 years ago
parent
commit
a577989f07
1 changed files with 35 additions and 31 deletions
  1. 35 31
      examples/08-update/update.cpp

+ 35 - 31
examples/08-update/update.cpp

@@ -157,47 +157,55 @@ bgfx::TextureHandle loadTextureWithUpdate(const char* _filePath, uint64_t _flags
 			BX_CHECK(1 >= imageContainer->m_depth, "3D Texture loading not supported");
 			BX_CHECK(1 == imageContainer->m_numLayers, "Texture Layer loading not supported");
 
-			if (!imageContainer->m_cubeMap &&
-				1 >= imageContainer->m_depth &&
-				1 == imageContainer->m_numLayers &&
-				bgfx::isTextureValid(0, false, imageContainer->m_numLayers, bgfx::TextureFormat::Enum(imageContainer->m_format), _flags)
-				)
+			if (!imageContainer->m_cubeMap
+			&&  1 >= imageContainer->m_depth
+			&&  1 == imageContainer->m_numLayers
+			&&  bgfx::isTextureValid(0, false, imageContainer->m_numLayers, bgfx::TextureFormat::Enum(imageContainer->m_format), _flags)
+			   )
 			{
 				handle = bgfx::createTexture2D(
-					uint16_t(imageContainer->m_width)
+					  uint16_t(imageContainer->m_width)
 					, uint16_t(imageContainer->m_height)
 					, 1 < imageContainer->m_numMips
 					, imageContainer->m_numLayers
 					, bgfx::TextureFormat::Enum(imageContainer->m_format)
 					, _flags
 					, NULL
-				);
+					);
 
 				uint32_t width = imageContainer->m_width;
 				uint32_t height = imageContainer->m_height;
 
 				for (uint8_t lod = 0, num = imageContainer->m_numMips; lod < num; ++lod)
 				{
-					if (width < 4 || height < 4) break;
-					width = bx::max(1u, width);
+					if (width < 4 || height < 4)
+					{
+						break;
+					}
+
+					width  = bx::max(1u, width);
 					height = bx::max(1u, height);
 
 					bimg::ImageMip mip;
+
 					if (bimg::imageGetRawData(*imageContainer, 0, lod, imageContainer->m_data, imageContainer->m_size, mip))
 					{
 						const uint8_t* mipData = mip.m_data;
 						uint32_t mipDataSize = mip.m_size;
 
-						bgfx::updateTexture2D(handle,
-							0,
-							lod,
-							0,
-							0,
-							uint16_t(width),
-							uint16_t(height),
-							bgfx::copy(mipData, mipDataSize));
+						bgfx::updateTexture2D(
+							  handle
+							, 0
+							, lod
+							, 0
+							, 0
+							, uint16_t(width)
+							, uint16_t(height)
+							, bgfx::copy(mipData, mipDataSize)
+							);
 					}
-					width >>= 1;
+
+					width  >>= 1;
 					height >>= 1;
 				}
 
@@ -336,15 +344,17 @@ public:
 		m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );
 
 		// Create programs.
-		m_program    = loadProgram("vs_update", "fs_update");
-		m_programCmp = loadProgram("vs_update", "fs_update_cmp");
+		m_program       = loadProgram("vs_update", "fs_update");
+		m_programCmp    = loadProgram("vs_update", "fs_update_cmp");
 		m_program3d.idx = bgfx::kInvalidHandle;
+
 		if (m_texture3DSupported)
 		{
 			m_program3d = loadProgram("vs_update", "fs_update_3d");
 		}
 
 		m_programCompute.idx = bgfx::kInvalidHandle;
+
 		if (m_computeSupported)
 		{
 			m_programCompute = bgfx::createProgram( loadShader( "cs_update" ), true );
@@ -524,19 +534,14 @@ public:
 
 			showExampleDialog(this);
 
-			ImGui::SetNextWindowPos(
-				ImVec2(10, 270.0f)
-				, ImGuiCond_FirstUseEver
-			);
-			ImGui::SetNextWindowSize(
-				ImVec2(150.0f, 70.0f)
-				, ImGuiCond_FirstUseEver
-			);
+			ImGui::SetNextWindowPos (ImVec2( 10.0f, 270.0f), ImGuiCond_FirstUseEver);
+			ImGui::SetNextWindowSize(ImVec2(150.0f,  70.0f), ImGuiCond_FirstUseEver);
 
-			ImGui::Begin("Show descriptions"
+			ImGui::Begin(
+				  "Show descriptions"
 				, NULL
 				, ImGuiWindowFlags_NoResize
-			);
+				);
 
 			if (ImGui::Button(m_showDescriptions ? "ON" : "OFF"))
 			{
@@ -723,7 +728,6 @@ public:
 				}
 			}
 
-
 			// Set view and projection matrix for view 1.
 			const uint32_t numColumns = BX_COUNTOF(m_textures) / 2;