mirror of
https://github.com/love2d/love.git
synced 2026-08-21 05:00:08 +02:00
Fixed some type conversion warnings in VC. Mostly float <-> int and bool <-> int.
This commit is contained in:
@@ -98,7 +98,7 @@ namespace love
|
|||||||
|
|
||||||
bool luax_toboolean(lua_State * L, int idx)
|
bool luax_toboolean(lua_State * L, int idx)
|
||||||
{
|
{
|
||||||
return (lua_toboolean(L, idx) == 1 ? true : false);
|
return (lua_toboolean(L, idx) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void luax_pushboolean(lua_State * L, bool b)
|
void luax_pushboolean(lua_State * L, bool b)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ namespace sdl
|
|||||||
case SDL_ACTIVEEVENT:
|
case SDL_ACTIVEEVENT:
|
||||||
if (e.active.state & SDL_APPINPUTFOCUS) {
|
if (e.active.state & SDL_APPINPUTFOCUS) {
|
||||||
m.type = Event::TYPE_FOCUS;
|
m.type = Event::TYPE_FOCUS;
|
||||||
m.focus.f = e.active.gain;
|
m.focus.f = (e.active.gain != 0);
|
||||||
return true;
|
return true;
|
||||||
} else break;
|
} else break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace sdl
|
|||||||
msg.joystick.button = luaL_checkint(L, 3);
|
msg.joystick.button = luaL_checkint(L, 3);
|
||||||
return true;
|
return true;
|
||||||
case Event::TYPE_FOCUS:
|
case Event::TYPE_FOCUS:
|
||||||
msg.focus.f = lua_toboolean(L, 2);
|
msg.focus.f = luax_toboolean(L, 2);
|
||||||
return true;
|
return true;
|
||||||
case Event::TYPE_QUIT:
|
case Event::TYPE_QUIT:
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ namespace physfs
|
|||||||
lua_pushstring(L, "Could not determine file modification date.");
|
lua_pushstring(L, "Could not determine file modification date.");
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
lua_pushnumber(L, time);
|
lua_pushnumber(L, static_cast<lua_Number>(time));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace opengl
|
|||||||
|
|
||||||
float Font::getHeight() const
|
float Font::getHeight() const
|
||||||
{
|
{
|
||||||
return height;
|
return static_cast<float>(height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::print(std::string text, float x, float y, float angle, float sx, float sy) const
|
void Font::print(std::string text, float x, float y, float angle, float sx, float sy) const
|
||||||
@@ -86,7 +86,7 @@ namespace opengl
|
|||||||
if (type == FONT_TRUETYPE) glTranslatef(0, floor(getHeight() / 1.25f + 0.5f), 0);
|
if (type == FONT_TRUETYPE) glTranslatef(0, floor(getHeight() / 1.25f + 0.5f), 0);
|
||||||
glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0);
|
glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glTranslatef(spacing[g], 0, 0);
|
glTranslatef(static_cast<GLfloat>(spacing[g]), 0, 0);
|
||||||
dx += spacing[g];
|
dx += spacing[g];
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
@@ -108,7 +108,7 @@ namespace opengl
|
|||||||
|
|
||||||
for(unsigned int i = 0; i < line.size(); i++)
|
for(unsigned int i = 0; i < line.size(); i++)
|
||||||
{
|
{
|
||||||
temp += (spacing[(int)line[i]] * mSpacing);
|
temp += static_cast<int>((spacing[(int)line[i]] * mSpacing));
|
||||||
}
|
}
|
||||||
|
|
||||||
return temp;
|
return temp;
|
||||||
@@ -144,7 +144,7 @@ namespace opengl
|
|||||||
temp = getWidth(text);
|
temp = getWidth(text);
|
||||||
linen++;
|
linen++;
|
||||||
}
|
}
|
||||||
temp += (spacing[(int)line[i]] * mSpacing);
|
temp += static_cast<int>((spacing[(int)line[i]] * mSpacing));
|
||||||
text += line[i];
|
text += line[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,11 +146,14 @@ namespace opengl
|
|||||||
{
|
{
|
||||||
strategy = NULL;
|
strategy = NULL;
|
||||||
|
|
||||||
|
float w = static_cast<float>(width);
|
||||||
|
float h = static_cast<float>(height);
|
||||||
|
|
||||||
// world coordinates
|
// world coordinates
|
||||||
vertices[0].x = 0; vertices[0].y = 0;
|
vertices[0].x = 0; vertices[0].y = 0;
|
||||||
vertices[1].x = 0; vertices[1].y = height;
|
vertices[1].x = 0; vertices[1].y = h;
|
||||||
vertices[2].x = width; vertices[2].y = height;
|
vertices[2].x = w; vertices[2].y = h;
|
||||||
vertices[3].x = width; vertices[3].y = 0;
|
vertices[3].x = w; vertices[3].y = 0;
|
||||||
|
|
||||||
// texture coordinates
|
// texture coordinates
|
||||||
vertices[0].s = 0; vertices[0].t = 1;
|
vertices[0].s = 0; vertices[0].t = 1;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace opengl
|
|||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
|
|
||||||
glMultMatrixf((const GLfloat*)t.getElements());
|
glMultMatrixf((const GLfloat*)t.getElements());
|
||||||
glTranslatef(data->getBearingX(), -data->getBearingY(), 0.0f);
|
glTranslatef(static_cast<float>(data->getBearingX()), static_cast<float>(-data->getBearingY()), 0.0f);
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|||||||
@@ -341,7 +341,12 @@ namespace opengl
|
|||||||
bmask = 0x00FF0000;
|
bmask = 0x00FF0000;
|
||||||
amask = 0xFF000000;
|
amask = 0xFF000000;
|
||||||
#endif
|
#endif
|
||||||
SDL_Surface * icon = SDL_CreateRGBSurfaceFrom(image->getData()->getData(), image->getWidth(), image->getHeight(), 32, image->getWidth() * 4, rmask, gmask, bmask, amask);
|
|
||||||
|
int w = static_cast<int>(image->getWidth());
|
||||||
|
int h = static_cast<int>(image->getHeight());
|
||||||
|
int pitch = static_cast<int>(image->getWidth() * 4);
|
||||||
|
|
||||||
|
SDL_Surface * icon = SDL_CreateRGBSurfaceFrom(image->getData()->getData(), w, h, 32, pitch, rmask, gmask, bmask, amask);
|
||||||
SDL_WM_SetIcon(icon, NULL);
|
SDL_WM_SetIcon(icon, NULL);
|
||||||
SDL_FreeSurface(icon);
|
SDL_FreeSurface(icon);
|
||||||
}
|
}
|
||||||
@@ -943,7 +948,7 @@ namespace opengl
|
|||||||
|
|
||||||
void Graphics::circle(DrawMode mode, float x, float y, float radius, int points )
|
void Graphics::circle(DrawMode mode, float x, float y, float radius, int points )
|
||||||
{
|
{
|
||||||
float two_pi = LOVE_M_PI * 2;
|
float two_pi = static_cast<float>(LOVE_M_PI * 2);
|
||||||
if(points <= 0) points = 1;
|
if(points <= 0) points = 1;
|
||||||
float angle_shift = (two_pi / points);
|
float angle_shift = (two_pi / points);
|
||||||
|
|
||||||
@@ -1125,7 +1130,7 @@ namespace opengl
|
|||||||
|
|
||||||
bool Graphics::hasFocus()
|
bool Graphics::hasFocus()
|
||||||
{
|
{
|
||||||
return SDL_GetAppState() & SDL_APPINPUTFOCUS;
|
return (SDL_GetAppState() & SDL_APPINPUTFOCUS) != 0;
|
||||||
}
|
}
|
||||||
} // opengl
|
} // opengl
|
||||||
} // graphics
|
} // graphics
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ namespace box2d
|
|||||||
|
|
||||||
bool Body::getAllowSleeping()
|
bool Body::getAllowSleeping()
|
||||||
{
|
{
|
||||||
return (body->m_flags & b2Body::e_allowSleepFlag);
|
return (body->m_flags & b2Body::e_allowSleepFlag) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Body::putToSleep()
|
void Body::putToSleep()
|
||||||
|
|||||||
Reference in New Issue
Block a user