more type correctness in new code

Change-Id: If6ba00dd10ef0c565c63d559e63ea4135ab4eea4
This commit is contained in:
Markus Mohrhard
2014-05-01 00:20:50 +02:00
parent f49f5e160e
commit 7f28c821fe

View File

@@ -193,7 +193,7 @@ void OpenGL3DRenderer::SetVertex(PackedVertex &packed,
{ // If not, it needs to be added in the output data. { // If not, it needs to be added in the output data.
vertex.push_back(packed.position); vertex.push_back(packed.position);
normal.push_back(packed.normal); normal.push_back(packed.normal);
unsigned short newindex = (unsigned short)vertex.size() - 1; size_t newindex = vertex.size() - 1;
indeices.push_back( newindex ); indeices.push_back( newindex );
VertexToOutIndex[ packed ] = newindex; VertexToOutIndex[ packed ] = newindex;
} }
@@ -224,7 +224,7 @@ void OpenGL3DRenderer::CreateActualRoundedCube(float fRadius, int iSubDivY, int
{ {
m_RoundBarMesh.iElementStartIndices[k] = indeices[k].size(); m_RoundBarMesh.iElementStartIndices[k] = indeices[k].size();
} }
for (unsigned int i = 0; i < vertices.size(); i += 3) for (size_t i = 0; i < vertices.size(); i += 3)
{ {
for (int k = 0; k < 3; k++) for (int k = 0; k < 3; k++)
{ {
@@ -538,7 +538,6 @@ int OpenGL3DRenderer::GenerateRoundCornerBar(std::vector<glm::vec3> &vertices, s
return iFacesAdded; return iFacesAdded;
} }
void OpenGL3DRenderer::GetFreq() void OpenGL3DRenderer::GetFreq()
{ {
#if 0 #if 0
@@ -560,10 +559,9 @@ double OpenGL3DRenderer::GetTime()
int OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon) int OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
{ {
int listNum; size_t listNum = polygon.verticesList.size();
listNum = polygon.verticesList.size();
glUseProgram(m_CommonProID); glUseProgram(m_CommonProID);
for (int i = 0; i < listNum; i++) for (size_t i = 0; i < listNum; i++)
{ {
//move the circle to the pos, and scale using the xScale and Y scale //move the circle to the pos, and scale using the xScale and Y scale
Vertices3D *pointList = polygon.verticesList.front(); Vertices3D *pointList = polygon.verticesList.front();
@@ -607,9 +605,8 @@ int OpenGL3DRenderer::RenderLine3D(Polygon3DInfo &polygon)
int OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon) int OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
{ {
int verticesNum, normalsNum; size_t verticesNum = polygon.verticesList.size();
verticesNum = polygon.verticesList.size(); size_t normalsNum = polygon.normalsList.size();
normalsNum = polygon.normalsList.size();
//check whether the number of vertices and normals are equal //check whether the number of vertices and normals are equal
if (verticesNum != normalsNum) if (verticesNum != normalsNum)
{ {
@@ -624,7 +621,7 @@ int OpenGL3DRenderer::RenderPolygon3D(Polygon3DInfo &polygon)
glUseProgram(m_3DProID); glUseProgram(m_3DProID);
glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]); glUniformMatrix4fv(m_3DViewID, 1, GL_FALSE, &m_3DView[0][0]);
glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]); glUniformMatrix4fv(m_3DProjectionID, 1, GL_FALSE, &m_3DProjection[0][0]);
for (int i = 0; i < verticesNum; i++) for (size_t i = 0; i < verticesNum; i++)
{ {
//move the circle to the pos, and scale using the xScale and Y scale //move the circle to the pos, and scale using the xScale and Y scale
Vertices3D *pointList = polygon.verticesList.front(); Vertices3D *pointList = polygon.verticesList.front();
@@ -689,8 +686,8 @@ int OpenGL3DRenderer::RenderPolygon3DObject()
return 0; return 0;
} }
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
int polygonNum = m_Polygon3DInfoList.size(); size_t polygonNum = m_Polygon3DInfoList.size();
for (int i = 0; i < polygonNum; i++) for (size_t i = 0; i < polygonNum; i++)
{ {
Polygon3DInfo &polygon = m_Polygon3DInfoList.front(); Polygon3DInfo &polygon = m_Polygon3DInfoList.front();
if (polygon.lineOnly || (!polygon.fillStyle)) if (polygon.lineOnly || (!polygon.fillStyle))
@@ -737,7 +734,6 @@ void OpenGL3DRenderer::SetLightInfo(bool lightOn, sal_Int32 color, const glm::ve
m_LightsInfo.light[m_LightsInfo.lightNum].lightPower = 1.0; m_LightsInfo.light[m_LightsInfo.lightNum].lightPower = 1.0;
m_LightsInfo.lightNum++; m_LightsInfo.lightNum++;
} }
} }
void OpenGL3DRenderer::AddShapePolygon3DObject(sal_Int32 color,bool lineOnly,sal_Int32 lineColor,long fillStyle,sal_Int32 specular) void OpenGL3DRenderer::AddShapePolygon3DObject(sal_Int32 color,bool lineOnly,sal_Int32 lineColor,long fillStyle,sal_Int32 specular)
@@ -822,7 +818,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
{ {
m_Polygon3DInfo.verticesList.push_back(m_Polygon3DInfo.vertices); m_Polygon3DInfo.verticesList.push_back(m_Polygon3DInfo.vertices);
//get the buttom surface to calc the camera org, just for the demo //get the buttom surface to calc the camera org, just for the demo
if ((m_Polygon3DInfo.vertices->size()) && (!m_bCameraUpdated)) if (m_Polygon3DInfo.vertices->size() && !m_bCameraUpdated)
{ {
float minX = m_Polygon3DInfo.vertices->at(0).x; float minX = m_Polygon3DInfo.vertices->at(0).x;
float maxX = m_Polygon3DInfo.vertices->at(0).x; float maxX = m_Polygon3DInfo.vertices->at(0).x;
@@ -830,7 +826,7 @@ void OpenGL3DRenderer::EndAddPolygon3DObjectPoint()
float maxZ = m_Polygon3DInfo.vertices->at(0).z; float maxZ = m_Polygon3DInfo.vertices->at(0).z;
float maxY = m_Polygon3DInfo.vertices->at(0).y; float maxY = m_Polygon3DInfo.vertices->at(0).y;
float minY = m_Polygon3DInfo.vertices->at(0).y; float minY = m_Polygon3DInfo.vertices->at(0).y;
for (unsigned int i = 1; i < m_Polygon3DInfo.vertices->size(); i++) for (size_t i = 1; i < m_Polygon3DInfo.vertices->size(); i++)
{ {
minX = std::min(minX, m_Polygon3DInfo.vertices->at(i).x); minX = std::min(minX, m_Polygon3DInfo.vertices->at(i).x);
maxX = std::max(maxX, m_Polygon3DInfo.vertices->at(i).x); maxX = std::max(maxX, m_Polygon3DInfo.vertices->at(i).x);
@@ -1150,8 +1146,8 @@ int OpenGL3DRenderer::RenderExtrude3DObject()
(void*)0 // array buffer offset (void*)0 // array buffer offset
); );
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_CubeElementBuf);
int extrude3DNum = m_Extrude3DList.size(); size_t extrude3DNum = m_Extrude3DList.size();
for (int i = 0; i < extrude3DNum; i++) for (size_t i = 0; i < extrude3DNum; i++)
{ {
Extrude3DInfo extrude3DInfo = m_Extrude3DList[i]; Extrude3DInfo extrude3DInfo = m_Extrude3DList[i];
glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer); glBindBuffer(GL_UNIFORM_BUFFER, m_3DUBOBuffer);
@@ -1244,9 +1240,9 @@ int OpenGL3DRenderer::ProcessUnrenderedShape()
glm::vec4 OpenGL3DRenderer::GetColorByIndex(int index) glm::vec4 OpenGL3DRenderer::GetColorByIndex(int index)
{ {
int r = index & 0xFF; sal_uInt8 r = index & 0xFF;
int g = (index >> 8) & 0xFF; sal_uInt8 g = (index >> 8) & 0xFF;
int b = (index >> 16) & 0xFF; sal_uInt8 b = (index >> 16) & 0xFF;
return glm::vec4(((float)r) / 255.0, ((float)g) / 255.0, ((float)b) / 255.0, 1.0); return glm::vec4(((float)r) / 255.0, ((float)g) / 255.0, ((float)b) / 255.0, 1.0);
} }