Commit ebb6f460 authored by hybrid's avatar hybrid

Use c++ casts instead of plain C ones.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@818 dfc29bdd-3216-0410-991c-e03cc46cb475
parent f67fcbc1
...@@ -67,7 +67,7 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -67,7 +67,7 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
0, 0, 0 // Layer Masks Ignored 0, 0, 0 // Layer Masks Ignored
}; };
for (int i=0; i<5; ++i) for (u32 i=0; i<5; ++i)
{ {
if (i == 1) if (i == 1)
{ {
...@@ -267,7 +267,7 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<s32>& screenSize, ...@@ -267,7 +267,7 @@ bool COpenGLDriver::genericDriverInit(const core::dimension2d<s32>& screenSize,
const GLubyte* renderer = glGetString(GL_RENDERER); const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* vendor = glGetString(GL_VENDOR); const GLubyte* vendor = glGetString(GL_VENDOR);
if (renderer && vendor) if (renderer && vendor)
os::Printer::log((const c8*)renderer, (const c8*)vendor, ELL_INFORMATION); os::Printer::log(reinterpret_cast<const c8*>(renderer), reinterpret_cast<const c8*>(vendor), ELL_INFORMATION);
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
CurrentTexture[i]=0; CurrentTexture[i]=0;
...@@ -512,7 +512,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -512,7 +512,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
{ {
case EVT_STANDARD: case EVT_STANDARD:
{ {
const S3DVertex* p = (const S3DVertex*)vertices; const S3DVertex* p = reinterpret_cast<const S3DVertex*>(vertices);
for ( i=0; i<vertexCount; i+=4) for ( i=0; i<vertexCount; i+=4)
{ {
p->Color.toOpenGLColor(&ColorBuffer[i]); p->Color.toOpenGLColor(&ColorBuffer[i]);
...@@ -522,7 +522,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -522,7 +522,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
break; break;
case EVT_2TCOORDS: case EVT_2TCOORDS:
{ {
const S3DVertex2TCoords* p = (const S3DVertex2TCoords*)vertices; const S3DVertex2TCoords* p = reinterpret_cast<const S3DVertex2TCoords*>(vertices);
for ( i=0; i<vertexCount; i+=4) for ( i=0; i<vertexCount; i+=4)
{ {
p->Color.toOpenGLColor(&ColorBuffer[i]); p->Color.toOpenGLColor(&ColorBuffer[i]);
...@@ -532,7 +532,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -532,7 +532,7 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
break; break;
case EVT_TANGENTS: case EVT_TANGENTS:
{ {
const S3DVertexTangents* p = (const S3DVertexTangents*)vertices; const S3DVertexTangents* p = reinterpret_cast<const S3DVertexTangents*>(vertices);
for ( i=0; i<vertexCount; i+=4) for ( i=0; i<vertexCount; i+=4)
{ {
p->Color.toOpenGLColor(&ColorBuffer[i]); p->Color.toOpenGLColor(&ColorBuffer[i]);
...@@ -560,36 +560,36 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -560,36 +560,36 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
switch (vType) switch (vType)
{ {
case EVT_STANDARD: case EVT_STANDARD:
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].Pos); glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Pos);
glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].Normal); glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Normal);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &((S3DVertex*)vertices)[0].TCoords); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].TCoords);
break; break;
case EVT_2TCOORDS: case EVT_2TCOORDS:
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Pos); glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Pos);
glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].Normal); glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Normal);
// texture coordinates // texture coordinates
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords);
if (MultiTextureExtension) if (MultiTextureExtension)
{ {
extGlClientActiveTexture(GL_TEXTURE1_ARB); extGlClientActiveTexture(GL_TEXTURE1_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &((S3DVertex2TCoords*)vertices)[0].TCoords2); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords2);
} }
break; break;
case EVT_TANGENTS: case EVT_TANGENTS:
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Pos); glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Pos);
glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Normal); glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Normal);
// texture coordinates // texture coordinates
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].TCoords); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].TCoords);
if (MultiTextureExtension) if (MultiTextureExtension)
{ {
extGlClientActiveTexture(GL_TEXTURE1_ARB); extGlClientActiveTexture(GL_TEXTURE1_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Tangent); glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Tangent);
extGlClientActiveTexture(GL_TEXTURE2_ARB); extGlClientActiveTexture(GL_TEXTURE2_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &((S3DVertexTangents*)vertices)[0].Binormal); glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Binormal);
} }
break; break;
} }
...@@ -750,10 +750,10 @@ void COpenGLDriver::draw2DImage(video::ITexture* texture, ...@@ -750,10 +750,10 @@ void COpenGLDriver::draw2DImage(video::ITexture* texture,
const core::dimension2d<s32>& ss = texture->getOriginalSize(); const core::dimension2d<s32>& ss = texture->getOriginalSize();
core::rect<f32> tcoords; core::rect<f32> tcoords;
tcoords.UpperLeftCorner.X = (f32)sourcePos.X / (f32)ss.Width; tcoords.UpperLeftCorner.X = sourcePos.X / static_cast<f32>(ss.Width);
tcoords.UpperLeftCorner.Y = (f32)sourcePos.Y / (f32)ss.Height; tcoords.UpperLeftCorner.Y = sourcePos.Y / static_cast<f32>(ss.Height);
tcoords.LowerRightCorner.X = ((f32)sourcePos.X +(f32)sourceSize.Width) / (f32)ss.Width; tcoords.LowerRightCorner.X = (sourcePos.X + sourceSize.Width) / static_cast<f32>(ss.Width);
tcoords.LowerRightCorner.Y = ((f32)sourcePos.Y + (f32)sourceSize.Height) / (f32)ss.Height; tcoords.LowerRightCorner.Y = (sourcePos.Y + sourceSize.Height) / static_cast<f32>(ss.Height);
core::rect<s32> poss(targetPos, sourceSize); core::rect<s32> poss(targetPos, sourceSize);
core::rect<f32> npos; core::rect<f32> npos;
...@@ -838,10 +838,10 @@ void COpenGLDriver::draw2DImage(video::ITexture* texture, ...@@ -838,10 +838,10 @@ void COpenGLDriver::draw2DImage(video::ITexture* texture,
sourcePos=sourceRects[currentIndex].UpperLeftCorner; sourcePos=sourceRects[currentIndex].UpperLeftCorner;
sourceSize=sourceRects[currentIndex].getSize(); sourceSize=sourceRects[currentIndex].getSize();
tcoords.UpperLeftCorner.X = (f32)sourceRects[currentIndex].UpperLeftCorner.X / (f32)ss.Width; tcoords.UpperLeftCorner.X = sourceRects[currentIndex].UpperLeftCorner.X / static_cast<f32>(ss.Width);
tcoords.UpperLeftCorner.Y = (f32)sourceRects[currentIndex].UpperLeftCorner.Y / (f32)ss.Height; tcoords.UpperLeftCorner.Y = sourceRects[currentIndex].UpperLeftCorner.Y / static_cast<f32>(ss.Height);
tcoords.LowerRightCorner.X = (f32)sourceRects[currentIndex].LowerRightCorner.X / (f32)ss.Width; tcoords.LowerRightCorner.X = sourceRects[currentIndex].LowerRightCorner.X / static_cast<f32>(ss.Width);
tcoords.LowerRightCorner.Y = (f32)sourceRects[currentIndex].LowerRightCorner.Y / (f32)ss.Height; tcoords.LowerRightCorner.Y = sourceRects[currentIndex].LowerRightCorner.Y / static_cast<f32>(ss.Height);
core::rect<s32> poss(targetPos, sourceSize); core::rect<s32> poss(targetPos, sourceSize);
core::rect<f32> npos; core::rect<f32> npos;
...@@ -884,15 +884,15 @@ void COpenGLDriver::draw2DImage(video::ITexture* texture, const core::rect<s32>& ...@@ -884,15 +884,15 @@ void COpenGLDriver::draw2DImage(video::ITexture* texture, const core::rect<s32>&
const core::dimension2d<s32>& ss = texture->getOriginalSize(); const core::dimension2d<s32>& ss = texture->getOriginalSize();
core::rect<f32> tcoords; core::rect<f32> tcoords;
tcoords.UpperLeftCorner.X = (f32)sourceRect.UpperLeftCorner.X / (f32)ss.Width; tcoords.UpperLeftCorner.X = sourceRect.UpperLeftCorner.X / static_cast<f32>(ss.Width);
tcoords.UpperLeftCorner.Y = (f32)sourceRect.UpperLeftCorner.Y / (f32)ss.Height; tcoords.UpperLeftCorner.Y = sourceRect.UpperLeftCorner.Y / static_cast<f32>(ss.Height);
tcoords.LowerRightCorner.X = (f32)sourceRect.LowerRightCorner.X / (f32)ss.Width; tcoords.LowerRightCorner.X = sourceRect.LowerRightCorner.X / static_cast<f32>(ss.Width);
tcoords.LowerRightCorner.Y = (f32)sourceRect.LowerRightCorner.Y / (f32)ss.Height; tcoords.LowerRightCorner.Y = sourceRect.LowerRightCorner.Y / static_cast<f32>(ss.Height);
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize(); const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
core::rect<f32> npos; core::rect<f32> npos;
f32 xFact = 2.0f / ( renderTargetSize.Width ); const f32 xFact = 2.0f / renderTargetSize.Width;
f32 yFact = 2.0f / ( renderTargetSize.Height ); const f32 yFact = 2.0f / renderTargetSize.Height;
npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f; npos.UpperLeftCorner.X = ( destRect.UpperLeftCorner.X * xFact ) - 1.0f;
npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact ); npos.UpperLeftCorner.Y = 1.0f - ( destRect.UpperLeftCorner.Y * yFact );
npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f; npos.LowerRightCorner.X = ( destRect.LowerRightCorner.X * xFact ) - 1.0f;
...@@ -965,11 +965,11 @@ void COpenGLDriver::draw2DRectangle(SColor color, const core::rect<s32>& positio ...@@ -965,11 +965,11 @@ void COpenGLDriver::draw2DRectangle(SColor color, const core::rect<s32>& positio
return; return;
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize(); const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
s32 xPlus = renderTargetSize.Width>>1; const s32 xPlus = renderTargetSize.Width/2;
f32 xFact = 1.0f / (renderTargetSize.Width>>1); const f32 xFact = 2.0f / renderTargetSize.Width/2;
s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height/2);
f32 yFact = 1.0f / (renderTargetSize.Height>>1); const f32 yFact = 2.0f / renderTargetSize.Height;
glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
glRectf((pos.UpperLeftCorner.X-xPlus) * xFact, glRectf((pos.UpperLeftCorner.X-xPlus) * xFact,
...@@ -994,17 +994,17 @@ void COpenGLDriver::draw2DRectangle(const core::rect<s32>& position, ...@@ -994,17 +994,17 @@ void COpenGLDriver::draw2DRectangle(const core::rect<s32>& position,
return; return;
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize(); const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
s32 xPlus = renderTargetSize.Width>>1; const s32 xPlus = renderTargetSize.Width/2;
f32 xFact = 1.0f / (renderTargetSize.Width>>1); const f32 xFact = 2.0f / renderTargetSize.Width;
s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1); const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height/2);
f32 yFact = 1.0f / (renderTargetSize.Height>>1); const f32 yFact = 2.0f / renderTargetSize.Height;
core::rect<f32> npos; core::rect<f32> npos;
npos.UpperLeftCorner.X = (f32)(pos.UpperLeftCorner.X-xPlus) * xFact; npos.UpperLeftCorner.X = (pos.UpperLeftCorner.X-xPlus) * xFact;
npos.UpperLeftCorner.Y = (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact; npos.UpperLeftCorner.Y = (yPlus-pos.UpperLeftCorner.Y) * yFact;
npos.LowerRightCorner.X = (f32)(pos.LowerRightCorner.X-xPlus) * xFact; npos.LowerRightCorner.X = (pos.LowerRightCorner.X-xPlus) * xFact;
npos.LowerRightCorner.Y = (f32)(yPlus-pos.LowerRightCorner.Y) * yFact; npos.LowerRightCorner.Y = (yPlus-pos.LowerRightCorner.Y) * yFact;
setRenderStates2DMode(colorLeftUp.getAlpha() < 255 || setRenderStates2DMode(colorLeftUp.getAlpha() < 255 ||
colorRightUp.getAlpha() < 255 || colorRightUp.getAlpha() < 255 ||
...@@ -1043,20 +1043,19 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start, ...@@ -1043,20 +1043,19 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
// thanks to Vash TheStampede who sent in his implementation // thanks to Vash TheStampede who sent in his implementation
const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize(); const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
const s32 xPlus = renderTargetSize.Width>>1; const s32 xPlus = renderTargetSize.Width/2;
const f32 xFact = 1.0f / (renderTargetSize.Width>>1); const f32 xFact = 2.0f / renderTargetSize.Width;
const s32 yPlus = const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height/2);
renderTargetSize.Height-(renderTargetSize.Height>>1); const f32 yFact = 2.0f / renderTargetSize.Height;
const f32 yFact = 1.0f / (renderTargetSize.Height>>1);
core::position2d<f32> npos_start; core::position2d<f32> npos_start;
npos_start.X = (f32)(start.X - xPlus) * xFact; npos_start.X = (start.X - xPlus) * xFact;
npos_start.Y = (f32)(yPlus - start.Y) * yFact; npos_start.Y = (yPlus - start.Y) * yFact;
core::position2d<f32> npos_end; core::position2d<f32> npos_end;
npos_end.X = (f32)(end.X - xPlus) * xFact; npos_end.X = (end.X - xPlus) * xFact;
npos_end.Y = (f32)(yPlus - end.Y) * yFact; npos_end.Y = (yPlus - end.Y) * yFact;
setRenderStates2DMode(color.getAlpha() < 255, false, false); setRenderStates2DMode(color.getAlpha() < 255, false, false);
disableTextures(); disableTextures();
...@@ -1070,7 +1069,7 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start, ...@@ -1070,7 +1069,7 @@ void COpenGLDriver::draw2DLine(const core::position2d<s32>& start,
bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture) bool COpenGLDriver::setTexture(u32 stage, video::ITexture* texture)
{ {
if (stage >= MaxTextureUnits) if (stage >= MaxTextureUnits)
return false; return false;
...@@ -1083,7 +1082,7 @@ bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture) ...@@ -1083,7 +1082,7 @@ bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture)
CurrentTexture[stage]=texture; CurrentTexture[stage]=texture;
if (texture == 0) if (!texture)
{ {
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
return true; return true;
...@@ -1099,7 +1098,7 @@ bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture) ...@@ -1099,7 +1098,7 @@ bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture)
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, glBindTexture(GL_TEXTURE_2D,
((COpenGLTexture*)texture)->getOpenGLTextureName()); static_cast<COpenGLTexture*>(texture)->getOpenGLTextureName());
} }
return true; return true;
} }
...@@ -1108,10 +1107,10 @@ bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture) ...@@ -1108,10 +1107,10 @@ bool COpenGLDriver::setTexture(s32 stage, video::ITexture* texture)
//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled.
//! Returns whether disabling was successful or not. //! Returns whether disabling was successful or not.
bool COpenGLDriver::disableTextures(s32 fromStage) bool COpenGLDriver::disableTextures(u32 fromStage)
{ {
bool result=true; bool result=true;
for (s32 i=fromStage; i<MaxTextureUnits; ++i) for (u32 i=fromStage; i<MaxTextureUnits; ++i)
result &= setTexture(i, 0); result &= setTexture(i, 0);
return result; return result;
} }
...@@ -1255,11 +1254,11 @@ void COpenGLDriver::setRenderStates3DMode() ...@@ -1255,11 +1254,11 @@ void COpenGLDriver::setRenderStates3DMode()
// unset old material // unset old material
if (LastMaterial.MaterialType != Material.MaterialType && if (LastMaterial.MaterialType != Material.MaterialType &&
LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size()) LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < static_cast<s32>(MaterialRenderers.size()))
MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial(); MaterialRenderers[LastMaterial.MaterialType].Renderer->OnUnsetMaterial();
// set new material. // set new material.
if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) if (Material.MaterialType >= 0 && Material.MaterialType < static_cast<s32>(MaterialRenderers.size()))
MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial( MaterialRenderers[Material.MaterialType].Renderer->OnSetMaterial(
Material, LastMaterial, ResetRenderStates, this); Material, LastMaterial, ResetRenderStates, this);
...@@ -1267,7 +1266,7 @@ void COpenGLDriver::setRenderStates3DMode() ...@@ -1267,7 +1266,7 @@ void COpenGLDriver::setRenderStates3DMode()
ResetRenderStates = false; ResetRenderStates = false;
} }
if (Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) if (Material.MaterialType >= 0 && Material.MaterialType < static_cast<s32>(MaterialRenderers.size()))
MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD); MaterialRenderers[Material.MaterialType].Renderer->OnRender(this, video::EVT_STANDARD);
CurrentRenderMode = ERM_3D; CurrentRenderMode = ERM_3D;
...@@ -1331,7 +1330,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1331,7 +1330,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
// Texture filter // Texture filter
// Has to be checked always because it depends on the textures // Has to be checked always because it depends on the textures
// Filtering has to be set for each texture layer // Filtering has to be set for each texture layer
for (s32 i=0; i<MaxTextureUnits; ++i) for (u32 i=0; i<MaxTextureUnits; ++i)
{ {
if (!material.Textures[i]) if (!material.Textures[i])
continue; continue;
...@@ -1447,7 +1446,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater ...@@ -1447,7 +1446,7 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial& material, const SMater
} }
// texture address mode // texture address mode
for (s32 u=0; u<MaxTextureUnits; ++u) for (u32 u=0; u<MaxTextureUnits; ++u)
{ {
if (resetAllRenderStates || lastmaterial.TextureWrap[u] != material.TextureWrap[u]) if (resetAllRenderStates || lastmaterial.TextureWrap[u] != material.TextureWrap[u])
{ {
...@@ -1535,7 +1534,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh ...@@ -1535,7 +1534,7 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh
{ {
// unset last 3d material // unset last 3d material
if (CurrentRenderMode == ERM_3D && Material.MaterialType >= 0 && if (CurrentRenderMode == ERM_3D && Material.MaterialType >= 0 &&
Material.MaterialType < (s32)MaterialRenderers.size()) Material.MaterialType < static_cast<s32>(MaterialRenderers.size()))
MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial();
GLfloat glmat[16]; GLfloat glmat[16];
...@@ -1793,7 +1792,7 @@ void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s3 ...@@ -1793,7 +1792,7 @@ void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s3
// unset last 3d material // unset last 3d material
if (CurrentRenderMode == ERM_3D && if (CurrentRenderMode == ERM_3D &&
Material.MaterialType >= 0 && Material.MaterialType < (s32)MaterialRenderers.size()) Material.MaterialType >= 0 && Material.MaterialType < static_cast<s32>(MaterialRenderers.size()))
{ {
MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial(); MaterialRenderers[Material.MaterialType].Renderer->OnUnsetMaterial();
ResetRenderStates = true; ResetRenderStates = true;
...@@ -2054,7 +2053,7 @@ E_DRIVER_TYPE COpenGLDriver::getDriverType() ...@@ -2054,7 +2053,7 @@ E_DRIVER_TYPE COpenGLDriver::getDriverType()
void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{ {
#ifdef GL_ARB_vertex_program #ifdef GL_ARB_vertex_program
for (int i=0; i<constantAmount; ++i) for (s32 i=0; i<constantAmount; ++i)
extGlProgramLocalParameter4fv(GL_VERTEX_PROGRAM_ARB, startRegister+i, &data[i*4]); extGlProgramLocalParameter4fv(GL_VERTEX_PROGRAM_ARB, startRegister+i, &data[i*4]);
#endif #endif
} }
...@@ -2063,7 +2062,7 @@ void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister, ...@@ -2063,7 +2062,7 @@ void COpenGLDriver::setVertexShaderConstant(const f32* data, s32 startRegister,
void COpenGLDriver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount) void COpenGLDriver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
{ {
#ifdef GL_ARB_fragment_program #ifdef GL_ARB_fragment_program
for (int i=0; i<constantAmount; ++i) for (s32 i=0; i<constantAmount; ++i)
extGlProgramLocalParameter4fv(GL_FRAGMENT_PROGRAM_ARB, startRegister+i, &data[i*4]); extGlProgramLocalParameter4fv(GL_FRAGMENT_PROGRAM_ARB, startRegister+i, &data[i*4]);
#endif #endif
} }
...@@ -2269,7 +2268,7 @@ IImage* COpenGLDriver::createScreenShot() ...@@ -2269,7 +2268,7 @@ IImage* COpenGLDriver::createScreenShot()
{ {
IImage* newImage = new CImage(ECF_R8G8B8, ScreenSize); IImage* newImage = new CImage(ECF_R8G8B8, ScreenSize);
u8* pPixels = (u8*)newImage->lock(); u8* pPixels = reinterpret_cast<u8*>(newImage->lock());
if (!pPixels) if (!pPixels)
{ {
newImage->drop(); newImage->drop();
......
...@@ -239,11 +239,11 @@ namespace video ...@@ -239,11 +239,11 @@ namespace video
//! sets the current Texture //! sets the current Texture
//! Returns whether setting was a success or not. //! Returns whether setting was a success or not.
bool setTexture(s32 stage, video::ITexture* texture); bool setTexture(u32 stage, video::ITexture* texture);
//! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled.
//! Returns whether disabling was successful or not. //! Returns whether disabling was successful or not.
bool disableTextures(s32 fromStage=0); bool disableTextures(u32 fromStage=0);
//! Adds a new material renderer to the VideoDriver, using extGLGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) pixel and/or //! Adds a new material renderer to the VideoDriver, using extGLGetObjectParameterivARB(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) pixel and/or
//! vertex shaders to render geometry. //! vertex shaders to render geometry.
......
...@@ -59,7 +59,7 @@ void COpenGLExtensionHandler::dump() const ...@@ -59,7 +59,7 @@ void COpenGLExtensionHandler::dump() const
void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
{ {
const f32 ver = core::fast_atof((c8*)glGetString(GL_VERSION)); const f32 ver = core::fast_atof(reinterpret_cast<const c8*>(glGetString(GL_VERSION)));
Version = core::floor32(ver)*100+core::ceil32((ver-floor(ver))*10.0); Version = core::floor32(ver)*100+core::ceil32((ver-floor(ver))*10.0);
if ( Version >= 102) if ( Version >= 102)
os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION); os::Printer::log("OpenGL driver version is 1.2 or better.", ELL_INFORMATION);
...@@ -67,25 +67,25 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -67,25 +67,25 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING); os::Printer::log("OpenGL driver version is not 1.2 or better.", ELL_WARNING);
const GLubyte* t = glGetString(GL_EXTENSIONS); const GLubyte* t = glGetString(GL_EXTENSIONS);
// os::Printer::log((const c8*)t, ELL_INFORMATION); // os::Printer::log(reinterpret_cast<const c8*>(t), ELL_INFORMATION);
#ifdef GLU_VERSION_1_3 #ifdef GLU_VERSION_1_3
const GLubyte* gluVersion = gluGetString(GLU_VERSION); const GLubyte* gluVersion = gluGetString(GLU_VERSION);
if (gluVersion[0]>1 || gluVersion[3]>2) if (gluVersion[0]>1 || gluVersion[3]>2)
{ {
for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i) for (u32 i=0; i<IRR_OpenGL_Feature_Count; ++i)
FeatureAvailable[i] = gluCheckExtension((const GLubyte*)OpenGLFeatureStrings[i], t); FeatureAvailable[i] = gluCheckExtension(reinterpret_cast<const GLubyte*>(OpenGLFeatureStrings[i]), t);
} }
else else
#endif #endif
{ {
s32 len = (s32)strlen((const char*)t); size_t len = strlen(reinterpret_cast<const char*>(t));
c8 *str = new c8[len+1]; c8 *str = new c8[len+1];
c8* p = str; c8* p = str;
for (s32 i=0; i<len; ++i) for (size_t i=0; i<len; ++i)
{ {
str[i] = (char)t[i]; str[i] = static_cast<char>(t[i]);
if (str[i] == ' ') if (str[i] == ' ')
{ {
...@@ -170,7 +170,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -170,7 +170,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT"); pGlFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
// vsync extension // vsync extension
wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC)wglGetProcAddress( "wglSwapIntervalEXT" ); wglSwapIntervalEXT = (PFNWGLSWAPINTERVALFARPROC) wglGetProcAddress("wglSwapIntervalEXT");
#elif defined(_IRR_USE_LINUX_DEVICE_) || defined (_IRR_USE_SDL_DEVICE_) #elif defined(_IRR_USE_LINUX_DEVICE_) || defined (_IRR_USE_SDL_DEVICE_)
#ifdef _IRR_OPENGL_USE_EXTPOINTER_ #ifdef _IRR_OPENGL_USE_EXTPOINTER_
...@@ -351,7 +351,11 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -351,7 +351,11 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
// set some properties // set some properties
#if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3) #if defined(GL_ARB_multitexture) || defined(GL_VERSION_1_3)
if (Version>102 || FeatureAvailable[IRR_ARB_multitexture]) if (Version>102 || FeatureAvailable[IRR_ARB_multitexture])
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &MaxTextureUnits); {
GLint num;
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &num);
MaxTextureUnits=num;
}
#endif #endif
glGetIntegerv(GL_MAX_LIGHTS, &MaxLights); glGetIntegerv(GL_MAX_LIGHTS, &MaxLights);
#ifdef GL_EXT_texture_filter_anisotropic #ifdef GL_EXT_texture_filter_anisotropic
...@@ -371,7 +375,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -371,7 +375,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
ShaderLanguageVersion = 100; ShaderLanguageVersion = 100;
else else
{ {
const f32 ver = core::fast_atof((c8*)shaderVersion); const f32 ver = core::fast_atof(reinterpret_cast<const c8*>(shaderVersion));
ShaderLanguageVersion = core::floor32(ver)*100+core::ceil32((ver-floor(ver))*10.0); ShaderLanguageVersion = core::floor32(ver)*100+core::ceil32((ver-floor(ver))*10.0);
} }
} }
...@@ -390,7 +394,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -390,7 +394,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
MultiTextureExtension = false; MultiTextureExtension = false;
os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING); os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING);
} }
MaxTextureUnits = core::min_((u32)MaxTextureUnits,MATERIAL_MAX_TEXTURES); MaxTextureUnits = core::min_(MaxTextureUnits,MATERIAL_MAX_TEXTURES);
} }
......
...@@ -670,7 +670,7 @@ class COpenGLExtensionHandler ...@@ -670,7 +670,7 @@ class COpenGLExtensionHandler
// Some non-boolean properties // Some non-boolean properties
//! Maxmimum texture layers supported by the fixed pipeline //! Maxmimum texture layers supported by the fixed pipeline
GLint MaxTextureUnits; u32 MaxTextureUnits;
//! Maximum hardware lights supported //! Maximum hardware lights supported
GLint MaxLights; GLint MaxLights;
//! Optimal number of indices per meshbuffer //! Optimal number of indices per meshbuffer
......
...@@ -22,8 +22,7 @@ class COpenGLMaterialRenderer : public IMaterialRenderer ...@@ -22,8 +22,7 @@ class COpenGLMaterialRenderer : public IMaterialRenderer
public: public:
//! Constructor //! Constructor
COpenGLMaterialRenderer(video::COpenGLDriver* driver) COpenGLMaterialRenderer(video::COpenGLDriver* driver) : Driver(driver)
: Driver(driver)
{ {
} }
......
...@@ -201,7 +201,7 @@ COpenGLNormalMapRenderer::COpenGLNormalMapRenderer(video::COpenGLDriver* driver, ...@@ -201,7 +201,7 @@ COpenGLNormalMapRenderer::COpenGLNormalMapRenderer(video::COpenGLDriver* driver,
if (renderer) if (renderer)
{ {
// use the already compiled shaders // use the already compiled shaders
video::COpenGLNormalMapRenderer* nmr = (video::COpenGLNormalMapRenderer*)renderer; video::COpenGLNormalMapRenderer* nmr = reinterpret_cast<video::COpenGLNormalMapRenderer*>(renderer);
CompiledShaders = false; CompiledShaders = false;
VertexShader = nmr->VertexShader; VertexShader = nmr->VertexShader;
......
...@@ -235,7 +235,7 @@ COpenGLParallaxMapRenderer::COpenGLParallaxMapRenderer(video::COpenGLDriver* dri ...@@ -235,7 +235,7 @@ COpenGLParallaxMapRenderer::COpenGLParallaxMapRenderer(video::COpenGLDriver* dri
if (renderer) if (renderer)
{ {
// use the already compiled shaders // use the already compiled shaders
video::COpenGLParallaxMapRenderer* nmr = (video::COpenGLParallaxMapRenderer*)renderer; video::COpenGLParallaxMapRenderer* nmr = reinterpret_cast<video::COpenGLParallaxMapRenderer*>(renderer);
CompiledShaders = false; CompiledShaders = false;
VertexShader = nmr->VertexShader; VertexShader = nmr->VertexShader;
......
...@@ -192,7 +192,7 @@ bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shad ...@@ -192,7 +192,7 @@ bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shad
#endif #endif
GLcharARB *pInfoLog = new GLcharARB[maxLength]; GLcharARB *pInfoLog = new GLcharARB[maxLength];
Driver->extGlGetInfoLog(shaderHandle, maxLength, &length, pInfoLog); Driver->extGlGetInfoLog(shaderHandle, maxLength, &length, pInfoLog);
os::Printer::log((const c8*)pInfoLog); os::Printer::log(reinterpret_cast<const c8*>(pInfoLog));
delete [] pInfoLog; delete [] pInfoLog;
return false; return false;
...@@ -225,7 +225,7 @@ bool COpenGLSLMaterialRenderer::linkProgram() ...@@ -225,7 +225,7 @@ bool COpenGLSLMaterialRenderer::linkProgram()
#endif #endif
GLcharARB *pInfoLog = new GLcharARB[maxLength]; GLcharARB *pInfoLog = new GLcharARB[maxLength];
Driver->extGlGetInfoLog(Program, maxLength, &length, pInfoLog); Driver->extGlGetInfoLog(Program, maxLength, &length, pInfoLog);
os::Printer::log((const c8*)pInfoLog); os::Printer::log(reinterpret_cast<const c8*>(pInfoLog));
delete [] pInfoLog; delete [] pInfoLog;
return false; return false;
...@@ -266,7 +266,7 @@ bool COpenGLSLMaterialRenderer::linkProgram() ...@@ -266,7 +266,7 @@ bool COpenGLSLMaterialRenderer::linkProgram()
memset(buf, 0, maxlen); memset(buf, 0, maxlen);
GLint size; GLint size;
Driver->extGlGetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, (GLcharARB*)buf); Driver->extGlGetActiveUniform(Program, i, maxlen, 0, &size, &ui.type, reinterpret_cast<GLcharARB*>(buf));
ui.name = buf; ui.name = buf;
UniformInfo.push_back(ui); UniformInfo.push_back(ui);
...@@ -301,9 +301,9 @@ void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 sta ...@@ -301,9 +301,9 @@ void COpenGLSLMaterialRenderer::setVertexShaderConstant(const f32* data, s32 sta
bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32* floats, int count) bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32* floats, int count)
{ {
int i = 0, num = (int)UniformInfo.size(); int i, num = static_cast<int>(UniformInfo.size());
for (; i < num; i++) for (i=0; i < num; ++i)
{ {
if (UniformInfo[i].name == name) if (UniformInfo[i].name == name)
break; break;
...@@ -337,7 +337,7 @@ bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32 ...@@ -337,7 +337,7 @@ bool COpenGLSLMaterialRenderer::setPixelShaderConstant(const c8* name, const f32
Driver->extGlUniformMatrix4fv(i, count/16, false, floats); Driver->extGlUniformMatrix4fv(i, count/16, false, floats);
break; break;
default: default:
Driver->extGlUniform1iv(i, count, (GLint*)floats); Driver->extGlUniform1iv(i, count, reinterpret_cast<const GLint*>(floats));
break; break;
} }
#endif #endif
......
...@@ -160,7 +160,8 @@ bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh) ...@@ -160,7 +160,8 @@ bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh)
Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader); Driver->extGlBindProgram(GL_FRAGMENT_PROGRAM_ARB, PixelShader);
// clear error buffer // clear error buffer
while(glGetError() != GL_NO_ERROR) {} while(glGetError() != GL_NO_ERROR)
{}
// compile // compile
Driver->extGlProgramString(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, Driver->extGlProgramString(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
...@@ -199,7 +200,8 @@ bool COpenGLShaderMaterialRenderer::createVertexShader(const char* vtxsh) ...@@ -199,7 +200,8 @@ bool COpenGLShaderMaterialRenderer::createVertexShader(const char* vtxsh)
Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader); Driver->extGlBindProgram(GL_VERTEX_PROGRAM_ARB, VertexShader);
// clear error buffer // clear error buffer
while(glGetError() != GL_NO_ERROR) {} while(glGetError() != GL_NO_ERROR)
{}
// compile // compile
Driver->extGlProgramString(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, Driver->extGlProgramString(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment