Commit def976c1 authored by hybrid's avatar hybrid

Fixed some minor warnings

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1804 dfc29bdd-3216-0410-991c-e03cc46cb475
parent bc536750
......@@ -15,7 +15,7 @@ namespace video
//! Creates a 16 bit A1R5G5B5 color
inline u16 RGBA16(u32 r, u32 g, u32 b, u32 a=0xFF)
{
return ((a & 0x80) << 8 |
return (u16)((a & 0x80) << 8 |
(r & 0xF8) << 7 |
(g & 0xF8) << 2 |
(b & 0xF8) >> 3);
......@@ -42,7 +42,7 @@ namespace video
//! Converts a 32bit (X8R8G8B8) color to a 16bit A1R5G5B5 color
inline u16 X8R8G8B8toA1R5G5B5(u32 color)
{
return (0x8000 |
return (u16)(0x8000 |
( color & 0x00F80000) >> 9 |
( color & 0x0000F800) >> 6 |
( color & 0x000000F8) >> 3);
......@@ -52,7 +52,7 @@ namespace video
//! Converts a 32bit (A8R8G8B8) color to a 16bit A1R5G5B5 color
inline u16 A8R8G8B8toA1R5G5B5(u32 color)
{
return (( color & 0x80000000) >> 16|
return (u16)(( color & 0x80000000) >> 16|
( color & 0x00F80000) >> 9 |
( color & 0x0000F800) >> 6 |
( color & 0x000000F8) >> 3);
......@@ -62,7 +62,7 @@ namespace video
//! Converts a 32bit (A8R8G8B8) color to a 16bit R5G6B5 color
inline u16 A8R8G8B8toR5G6B5(u32 color)
{
return (( color & 0x00F80000) >> 8 |
return (u16)(( color & 0x00F80000) >> 8 |
( color & 0x0000FC00) >> 5 |
( color & 0x000000F8) >> 3);
}
......@@ -232,10 +232,10 @@ namespace video
\param dest: address where the 4x8 bit OpenGL color is stored. */
void toOpenGLColor(u8* dest) const
{
*dest = getRed();
*++dest = getGreen();
*++dest = getBlue();
*++dest = getAlpha();
*dest = (u8)getRed();
*++dest = (u8)getGreen();
*++dest = (u8)getBlue();
*++dest = (u8)getAlpha();
}
//! Sets all four components of the color at once.
......
......@@ -354,7 +354,7 @@ static void RenderLine16_Decal(video::IImage *t,
run = dx;
while ( run )
{
*dst = argb;
*dst = (u16)argb;
dst = (u16*) ( (u8*) dst + xInc ); // x += xInc
d += m;
......@@ -1150,9 +1150,9 @@ void CImage::setPixel(u32 x, u32 y, const SColor &color )
case ECF_R8G8B8:
{
u8* dest = (u8*) Data + ( y * Pitch ) + ( x * 3 );
dest[0] = color.getRed();
dest[1] = color.getGreen();
dest[2] = color.getBlue();
dest[0] = (u8)color.getRed();
dest[1] = (u8)color.getGreen();
dest[2] = (u8)color.getBlue();
} break;
case ECF_A8R8G8B8:
......
......@@ -100,7 +100,7 @@ void CImageLoaderBMP::decompress8BitRLE(u8*& bmpData, s32 size, s32 width, s32 h
else
{
s32 count = (u8)*p; ++p;
s32 color = (u8)*p; ++p;
u8 color = *p; ++p;
for (s32 i=0; i<count; ++i)
{
*d = color;
......
......@@ -144,7 +144,7 @@ IImage* CImageLoaderPPM::loadImage(io::IReadFile* file) const
for (u32 i=0; i<size; ++i)
{
getNextToken(file, token);
const u32 num = core::strtol10(token.c_str());
const u8 num = (u8)core::strtol10(token.c_str());
*ptr++ = num;
*ptr++ = num;
*ptr++ = num;
......@@ -186,11 +186,11 @@ IImage* CImageLoaderPPM::loadImage(io::IReadFile* file) const
for (u32 i=0; i<size; ++i)
{
getNextToken(file, token);
*ptr++ = core::strtol10(token.c_str());
*ptr++ = (u8)core::strtol10(token.c_str());
getNextToken(file, token);
*ptr++ = core::strtol10(token.c_str());
*ptr++ = (u8)core::strtol10(token.c_str());
getNextToken(file, token);
*ptr++ = core::strtol10(token.c_str());
*ptr++ = (u8)core::strtol10(token.c_str());
*ptr++ = 255;
}
}
......
......@@ -175,7 +175,7 @@ bool CImageLoaderPSD::readRawImageData(io::IReadFile* file, const PsdHeader& hea
break;
}
s16 shift = getShiftFromChannel(channel, header);
s16 shift = getShiftFromChannel((c8)channel, header);
if (shift != -1)
{
u32 mask = 0xff << shift;
......@@ -316,7 +316,7 @@ bool CImageLoaderPSD::readRLEImageData(io::IReadFile* file, const PsdHeader& hea
}
}
s16 shift = getShiftFromChannel(channel, header);
s16 shift = getShiftFromChannel((c8)channel, header);
if (shift != -1)
{
......
......@@ -136,11 +136,11 @@ bool CImageWriterPCX::writeImage(io::IWriteFile *file, IImage *image,u32 param)
}
cnt=1;
if (j==0)
value=pix.getRed();
value=(u8)pix.getRed();
else if (j==1)
value=pix.getGreen();
value=(u8)pix.getGreen();
else if (j==2)
value=pix.getBlue();
value=(u8)pix.getBlue();
}
}
}
......
......@@ -40,7 +40,7 @@ bool CImageWriterPPM::isAWriteableFileExtension(const c8* fileName) const
bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image, u32 param) const
{
char cache[70];
char size;
int size;
const core::dimension2d<s32>& imageSize = image->getDimension();
......@@ -69,9 +69,9 @@ bool CImageWriterPPM::writeImage(io::IWriteFile *file, IImage *image, u32 param)
for (s32 c = 0; c < imageSize.Width; ++c)
{
const video::SColor& pixel = image->getPixel(c, h);
const u8 r = pixel.getRed() & 0xff;
const u8 g = pixel.getGreen() & 0xff;
const u8 b = pixel.getBlue() & 0xff;
const u8 r = (u8)(pixel.getRed() & 0xff);
const u8 g = (u8)(pixel.getGreen() & 0xff);
const u8 b = (u8)(pixel.getBlue() & 0xff);
file->write(&r, 1);
file->write(&g, 1);
file->write(&b, 1);
......
......@@ -636,7 +636,7 @@ bool CIrrDeviceWin32::present(video::IImage* image, void* windowId, core::rect<s
BITMAPV4HEADER bi;
ZeroMemory (&bi, sizeof(bi));
bi.bV4Size = sizeof(BITMAPINFOHEADER);
bi.bV4BitCount = image->getBitsPerPixel();
bi.bV4BitCount = (WORD)image->getBitsPerPixel();
bi.bV4Planes = 1;
bi.bV4Width = image->getDimension().Width;
bi.bV4Height = -image->getDimension().Height;
......@@ -803,7 +803,8 @@ void CIrrDeviceWin32::getWindowsVersion(core::stringc& out)
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (!(bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi)))
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO*) &osvi);
if (!bOsVersionInfoEx)
{
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (! GetVersionEx((OSVERSIONINFO *) &osvi))
......@@ -991,7 +992,7 @@ bool CIrrDeviceWin32::activateJoysticks(core::array<SJoystickInfo> & joystickInf
activeJoystick.Index = joystick;
ActiveJoysticks.push_back(activeJoystick);
returnInfo.Joystick = joystick;
returnInfo.Joystick = (u8)joystick;
returnInfo.Axes = activeJoystick.Caps.wNumAxes;
returnInfo.Buttons = activeJoystick.Caps.wNumButtons;
returnInfo.Name = activeJoystick.Caps.szPname;
......@@ -1012,9 +1013,9 @@ bool CIrrDeviceWin32::activateJoysticks(core::array<SJoystickInfo> & joystickInf
}
return true;
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
#else
return false;
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
}
void CIrrDeviceWin32::pollJoysticks()
......@@ -1036,7 +1037,7 @@ void CIrrDeviceWin32::pollJoysticks()
const JOYCAPS & caps = ActiveJoysticks[joystick].Caps;
event.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
event.JoystickEvent.Joystick = joystick;
event.JoystickEvent.Joystick = (u8)joystick;
event.JoystickEvent.POV = (u16)info.dwPOV;
if(event.JoystickEvent.POV > 35900)
......
......@@ -1511,7 +1511,7 @@ void CNullDriver::fillMaterialStructureFromAttributes(video::SMaterial& outMater
outMaterial.GouraudShading = attr->getAttributeAsBool("GouraudShading");
outMaterial.Lighting = attr->getAttributeAsBool("Lighting");
outMaterial.ZWriteEnable = attr->getAttributeAsBool("ZWriteEnable");
outMaterial.ZBuffer = attr->getAttributeAsInt("ZBuffer");
outMaterial.ZBuffer = (char)attr->getAttributeAsInt("ZBuffer");
outMaterial.BackfaceCulling = attr->getAttributeAsBool("BackfaceCulling");
outMaterial.FrontfaceCulling = attr->getAttributeAsBool("FrontfaceCulling");
outMaterial.FogEnable = attr->getAttributeAsBool("FogEnable");
......
......@@ -126,7 +126,7 @@ bool COBJMeshWriter::writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 fla
file->write(num.c_str(), num.size());
file->write("\n",1);
const u16 indexCount = buffer->getIndexCount();
const u32 indexCount = buffer->getIndexCount();
for (j=0; j<indexCount; j+=3)
{
file->write("f ",2);
......
......@@ -158,7 +158,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params)
}
// choose pixelformat
if ((PixelFormat = ChoosePixelFormat(HDc, &pfd)))
PixelFormat = ChoosePixelFormat(HDc, &pfd);
if (PixelFormat)
break;
}
......@@ -233,7 +234,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params)
}
// get hdc
if (!(HDc=GetDC(Window)))
HDc=GetDC(Window);
if (!HDc)
{
os::Printer::log("Cannot create a GL device context.", ELL_ERROR);
return false;
......@@ -275,7 +277,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params)
}
// choose pixelformat
if ((PixelFormat = ChoosePixelFormat(HDc, &pfd)))
PixelFormat = ChoosePixelFormat(HDc, &pfd);
if (PixelFormat)
break;
}
}
......@@ -288,7 +291,8 @@ bool COpenGLDriver::initDriver(irr::SIrrlichtCreationParameters params)
}
// create rendering context
if (!(HRc=wglCreateContext(HDc)))
HRc=wglCreateContext(HDc);
if (!HRc)
{
os::Printer::log("Cannot create a GL rendering context.", ELL_ERROR);
return false;
......
......@@ -524,12 +524,12 @@ void CParticleSystemSceneNode::reallocateBuffers()
for (i=oldIdxSize; i<Buffer->Indices.size(); i+=6)
{
Buffer->Indices[0+i] = 0+oldvertices;
Buffer->Indices[1+i] = 2+oldvertices;
Buffer->Indices[2+i] = 1+oldvertices;
Buffer->Indices[3+i] = 0+oldvertices;
Buffer->Indices[4+i] = 3+oldvertices;
Buffer->Indices[5+i] = 2+oldvertices;
Buffer->Indices[0+i] = (u16)0+oldvertices;
Buffer->Indices[1+i] = (u16)2+oldvertices;
Buffer->Indices[2+i] = (u16)1+oldvertices;
Buffer->Indices[3+i] = (u16)0+oldvertices;
Buffer->Indices[4+i] = (u16)3+oldvertices;
Buffer->Indices[5+i] = (u16)2+oldvertices;
oldvertices += 4;
}
}
......
......@@ -90,7 +90,7 @@ bool CSTLMeshWriter::writeMeshBinary(io::IWriteFile* file, scene::IMesh* mesh, s
IMeshBuffer* buffer = mesh->getMeshBuffer(i);
if (buffer)
{
const u16 indexCount = buffer->getIndexCount();
const u32 indexCount = buffer->getIndexCount();
const u16 attributes = 0;
for (u32 j=0; j<indexCount; j+=3)
{
......@@ -126,9 +126,7 @@ bool CSTLMeshWriter::writeMeshASCII(io::IWriteFile* file, scene::IMesh* mesh, s3
IMeshBuffer* buffer = mesh->getMeshBuffer(i);
if (buffer)
{
const u16 indexCount = buffer->getIndexCount();
const u32 indexCount = buffer->getIndexCount();
for (u32 j=0; j<indexCount; j+=3)
{
writeFace(file,
......
......@@ -556,12 +556,12 @@ namespace scene
const s32 index12 = getIndex( j, i, index, x, z + step );
const s32 index22 = getIndex( j, i, index, x + step, z + step );
IndexBuffer[IndicesToRender++]= index12;
IndexBuffer[IndicesToRender++]= index11;
IndexBuffer[IndicesToRender++]= index22;
IndexBuffer[IndicesToRender++]= index22;
IndexBuffer[IndicesToRender++]= index11;
IndexBuffer[IndicesToRender++]= index21;
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index12);
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index11);
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index22);
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index22);
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index11);
IndexBuffer[IndicesToRender++]= static_cast<INDEX_TYPE>(index21);
// increment index position horizontally
x += step;
......
......@@ -210,12 +210,12 @@ void CBillboardTextSceneNode::setText(const wchar_t* text)
buf->Vertices[firstVert+1].Color = ColorTop;
buf->Vertices[firstVert+2].Color = ColorTop;
buf->Indices[firstInd+0] = firstVert+0;
buf->Indices[firstInd+1] = firstVert+2;
buf->Indices[firstInd+2] = firstVert+1;
buf->Indices[firstInd+3] = firstVert+0;
buf->Indices[firstInd+4] = firstVert+3;
buf->Indices[firstInd+5] = firstVert+2;
buf->Indices[firstInd+0] = (u16)firstVert+0;
buf->Indices[firstInd+1] = (u16)firstVert+2;
buf->Indices[firstInd+2] = (u16)firstVert+1;
buf->Indices[firstInd+3] = (u16)firstVert+0;
buf->Indices[firstInd+4] = (u16)firstVert+3;
buf->Indices[firstInd+5] = (u16)firstVert+2;
wchar_t *tp = 0;
if (i>0)
......
......@@ -53,7 +53,7 @@ void CVolumeLightSceneNode::addToBuffer(const video::S3DVertex& v)
const bool alreadyIn = (tnidx != -1);
u16 nidx = (u16)tnidx;
if (!alreadyIn) {
nidx = Buffer->Vertices.size();
nidx = (u16)Buffer->Vertices.size();
Buffer->Indices.push_back(nidx);
Buffer->Vertices.push_back(v);
} else
......
......@@ -30,7 +30,7 @@ namespace irr
SIrrlichtCreationParameters p;
p.DriverType = driverType;
p.WindowSize = windowSize;
p.Bits = bits;
p.Bits = (u8)bits;
p.Fullscreen = fullscreen;
p.Stencilbuffer = stencilbuffer;
p.Vsync = vsync;
......
......@@ -199,7 +199,7 @@ inline u16 PixelBlend16 ( const u16 c2, const u32 c1, const u32 alpha )
rb &= 0x7C1F;
xg &= 0x03E0;
return rb | xg;
return (u16)(rb | xg);
}
/*!
......@@ -237,7 +237,7 @@ inline u32 extractAlpha ( const u32 c )
*/
inline u16 PixelMul16 ( const u16 c0, const u16 c1)
{
return ((( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 ) |
return (u16)((( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 ) |
(( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 ) |
(( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 ) |
(c0 & 0x8000));
......@@ -248,10 +248,10 @@ inline u16 PixelMul16 ( const u16 c0, const u16 c1)
*/
inline u16 PixelMul16_2 ( u16 c0, u16 c1)
{
return ( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 |
return (u16)(( ( (c0 & 0x7C00) * (c1 & 0x7C00) ) & 0x3E000000 ) >> 15 |
( ( (c0 & 0x03E0) * (c1 & 0x03E0) ) & 0x000F8000 ) >> 10 |
( ( (c0 & 0x001F) * (c1 & 0x001F) ) & 0x000003E0 ) >> 5 |
( c0 & c1 & 0x8000);
( c0 & c1 & 0x8000));
}
/*
......
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