Browse Source

Fixed C4244 warnings.

bkaradzic 12 years ago
parent
commit
b25a7cc9ff
3 changed files with 19 additions and 30 deletions
  1. 0 12
      examples/common/cube_atlas.h
  2. 13 12
      examples/common/font/text_buffer_manager.cpp
  3. 6 6
      src/vertexdecl.cpp

+ 0 - 12
examples/common/cube_atlas.h

@@ -89,18 +89,6 @@ public:
 	/// Same as packUV but pack a whole face of the atlas cube, mostly used for debugging and visualizing atlas
 	void packFaceLayerUV(uint32_t _idx, uint8_t* _vertexBuffer, uint32_t _offset, uint32_t _stride) const;
 
-	/// Pack the vertex index of the region as 2 quad into an index buffer
-	static void packIndex(uint16_t* _indexBuffer, uint32_t _startIndex, uint32_t _startVertex)
-	{
-		uint16_t* indices = &_indexBuffer[_startIndex];
-		*indices++ = _startVertex + 0;
-		*indices++ = _startVertex + 1;
-		*indices++ = _startVertex + 2;
-		*indices++ = _startVertex + 0;
-		*indices++ = _startVertex + 2;
-		*indices++ = _startVertex + 3;
-	}
-
 	/// return the TextureHandle (cube) of the atlas
 	bgfx::TextureHandle getTextureHandle() const
 	{

+ 13 - 12
examples/common/font/text_buffer_manager.cpp

@@ -184,9 +184,9 @@ private:
 	uint16_t* m_indexBuffer;
 	uint8_t* m_styleBuffer;
 
-	uint32_t m_vertexCount;
 	uint32_t m_indexCount;
 	uint32_t m_lineStartIndex;
+	uint16_t m_vertexCount;
 };
 
 TextBuffer::TextBuffer(FontManager* _fontManager)
@@ -384,17 +384,18 @@ void TextBuffer::appendGlyph(FontHandle _handle, CodePoint _codePoint)
 			, sizeof(TextVertex)
 			);
 
-		setVertex(m_vertexCount + 0, x0, y0, m_backgroundColor, STYLE_BACKGROUND);
-		setVertex(m_vertexCount + 1, x0, y1, m_backgroundColor, STYLE_BACKGROUND);
-		setVertex(m_vertexCount + 2, x1, y1, m_backgroundColor, STYLE_BACKGROUND);
-		setVertex(m_vertexCount + 3, x1, y0, m_backgroundColor, STYLE_BACKGROUND);
-
-		m_indexBuffer[m_indexCount + 0] = m_vertexCount + 0;
-		m_indexBuffer[m_indexCount + 1] = m_vertexCount + 1;
-		m_indexBuffer[m_indexCount + 2] = m_vertexCount + 2;
-		m_indexBuffer[m_indexCount + 3] = m_vertexCount + 0;
-		m_indexBuffer[m_indexCount + 4] = m_vertexCount + 2;
-		m_indexBuffer[m_indexCount + 5] = m_vertexCount + 3;
+		const uint16_t vertexCount = m_vertexCount;
+		setVertex(vertexCount + 0, x0, y0, m_backgroundColor, STYLE_BACKGROUND);
+		setVertex(vertexCount + 1, x0, y1, m_backgroundColor, STYLE_BACKGROUND);
+		setVertex(vertexCount + 2, x1, y1, m_backgroundColor, STYLE_BACKGROUND);
+		setVertex(vertexCount + 3, x1, y0, m_backgroundColor, STYLE_BACKGROUND);
+
+		m_indexBuffer[m_indexCount + 0] = vertexCount + 0;
+		m_indexBuffer[m_indexCount + 1] = vertexCount + 1;
+		m_indexBuffer[m_indexCount + 2] = vertexCount + 2;
+		m_indexBuffer[m_indexCount + 3] = vertexCount + 0;
+		m_indexBuffer[m_indexCount + 4] = vertexCount + 2;
+		m_indexBuffer[m_indexCount + 5] = vertexCount + 3;
 		m_vertexCount += 4;
 		m_indexCount += 6;
 	}

+ 6 - 6
src/vertexdecl.cpp

@@ -511,7 +511,7 @@ namespace bgfx
 				continue;
 			}
 
-			_output[ii] = ii;
+			_output[ii] = (uint16_t)ii;
 			++numVertices;
 
 			float pos[4];
@@ -529,12 +529,12 @@ namespace bgfx
 
 				if (sqLength(test, pos) < epsilonSq)
 				{
-					_output[jj] = ii;
+					_output[jj] = (uint16_t)ii;
 				}
 			}
 		}
 
-		return numVertices;
+		return (uint16_t)numVertices;
 	}
 
 	uint16_t weldVertices(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon)
@@ -572,13 +572,13 @@ namespace bgfx
 
 			if (UINT16_MAX == offset)
 			{
-				_output[ii] = ii;
+				_output[ii] = (uint16_t)ii;
 				next[ii] = hashTable[hashValue];
-				hashTable[hashValue] = ii;
+				hashTable[hashValue] = (uint16_t)ii;
 				numVertices++;
 			}
 		}
 
-		return numVertices;
+		return (uint16_t)numVertices;
 	}
 } // namespace bgfx