Просмотр исходного кода

Added warning for bad API use.

Бранимир Караџић 6 лет назад
Родитель
Сommit
9cd697b1af
1 измененных файлов с 13 добавлено и 1 удалено
  1. 13 1
      src/bgfx.cpp

+ 13 - 1
src/bgfx.cpp

@@ -4062,7 +4062,19 @@ namespace bgfx
 
 	uint16_t getShaderUniforms(ShaderHandle _handle, UniformHandle* _uniforms, uint16_t _max)
 	{
-		return s_ctx->getShaderUniforms(_handle, _uniforms, _max);
+		BX_WARN(NULL == _uniforms || 0 != _max
+			, "Passing uniforms array pointer, but array maximum capacity is set to 0."
+			);
+
+		uint16_t num = s_ctx->getShaderUniforms(_handle, _uniforms, _max);
+
+		BX_WARN(0 == _max || num <= _max
+			, "Shader has more uniforms that capacity of output array. Output is truncated (num %d, max %d)."
+			, num
+			, _max
+			);
+
+		return num;
 	}
 
 	void setName(ShaderHandle _handle, const char* _name, int32_t _len)