Forráskód Böngészése

world: create uniform with correct type

Daniele Bartolini 4 éve
szülő
commit
c34c1f54dd
2 módosított fájl, 12 hozzáadás és 1 törlés
  1. 1 0
      docs/changelog.rst
  2. 11 1
      src/world/material_manager.cpp

+ 1 - 0
docs/changelog.rst

@@ -12,6 +12,7 @@ Changelog
 **Runtime**
 
 * Added --pumped mode to skip rendering of frames unless explicitly requested.
+* Fixed the creation of uniforms with ``matrix4x4`` type.
 
 **Tools**
 

+ 11 - 1
src/world/material_manager.cpp

@@ -14,6 +14,16 @@
 
 namespace crown
 {
+static const bgfx::UniformType::Enum s_bgfx_uniform_type[] =
+{
+	bgfx::UniformType::Vec4, // UniformType::FLOAT
+	bgfx::UniformType::Vec4, // UniformType::VECTOR2
+	bgfx::UniformType::Vec4, // UniformType::VECTOR3
+	bgfx::UniformType::Vec4, // UniformType::VECTOR4
+	bgfx::UniformType::Mat4  // UniformType::MATRIX4X4
+};
+CE_STATIC_ASSERT(countof(s_bgfx_uniform_type) == UniformType::COUNT);
+
 MaterialManager::MaterialManager(Allocator& a, ResourceManager& rm)
 	: _allocator(&a)
 	, _resource_manager(&rm)
@@ -61,7 +71,7 @@ void MaterialManager::online(StringId64 id, ResourceManager& rm)
 	{
 		UniformData* ud    = uniform_data(mr, i);
 		UniformHandle* uh  = uniform_handle(mr, i, base);
-		uh->uniform_handle = bgfx::createUniform(uniform_name(mr, ud), bgfx::UniformType::Vec4).idx;
+		uh->uniform_handle = bgfx::createUniform(uniform_name(mr, ud), s_bgfx_uniform_type[ud->type]).idx;
 	}
 }