Browse Source

Added warning when passing zero as framebuffer/rendertarget resolution.

bkaradzic 13 years ago
parent
commit
68af253169
2 changed files with 5 additions and 3 deletions
  1. 2 1
      src/bgfx.cpp
  2. 3 2
      src/bgfx_p.h

+ 2 - 1
src/bgfx.cpp

@@ -1197,7 +1197,8 @@ namespace bgfx
 	RenderTargetHandle createRenderTarget(uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags)
 	{
 		BGFX_CHECK_MAIN_THREAD();
-		return s_ctx.createRenderTarget(_width, _height, _flags, _textureFlags);
+		BX_WARN(0 != _width && 0 != _height, "Render target resolution width or height cannot be 0 (width %d, height %d).", _width, _height);
+		return s_ctx.createRenderTarget(uint16_max(1, _width), uint16_max(1, _height), _flags, _textureFlags);
 	}
 
 	void destroyRenderTarget(RenderTargetHandle _handle)

+ 3 - 2
src/bgfx_p.h

@@ -1477,8 +1477,9 @@ namespace bgfx
 
 		void reset(uint32_t _width, uint32_t _height, uint32_t _flags)
 		{
-			m_resolution.m_width = _width;
-			m_resolution.m_height = _height;
+			BX_WARN(0 != _width && 0 != _height, "Frame buffer resolution width or height cannot be 0 (width %d, height %d).", _width, _height);
+			m_resolution.m_width = uint32_max(1, _width);
+			m_resolution.m_height = uint32_max(1, _height);
 			m_resolution.m_flags = _flags;
 
 			memset(m_rt, 0xff, sizeof(m_rt) );