瀏覽代碼

nanovg: Allow texture update after creation.

Branimir Karadžić 10 年之前
父節點
當前提交
6af72ce686
共有 1 個文件被更改,包括 18 次插入2 次删除
  1. 18 2
      examples/common/nanovg/nanovg_bgfx.cpp

+ 18 - 2
examples/common/nanovg/nanovg_bgfx.cpp

@@ -329,9 +329,20 @@ namespace
 						, 1
 						, NVG_TEXTURE_RGBA == _type ? bgfx::TextureFormat::RGBA8 : bgfx::TextureFormat::R8
 						, BGFX_TEXTURE_NONE
-						, mem
 						);
 
+		if (NULL != mem)
+		{
+			bgfx::updateTexture2D(tex->id
+					, 0
+					, 0
+					, 0
+					, tex->width
+					, tex->height
+					, mem
+					);
+		}
+
 		return bgfx::isValid(tex->id) ? tex->id.idx : 0;
 	}
 
@@ -353,7 +364,12 @@ namespace
 		uint32_t bytesPerPixel = NVG_TEXTURE_RGBA == tex->type ? 4 : 1;
 		uint32_t pitch = tex->width * bytesPerPixel;
 
-		bgfx::updateTexture2D(tex->id, 0, x, y, w, h
+		bgfx::updateTexture2D(tex->id
+				, 0
+				, x
+				, y
+				, w
+				, h
 				, bgfx::copy(data + y*pitch + x*bytesPerPixel, h*pitch)
 				, pitch
 				);