Skip to content

Commit

Permalink
Fix some compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Dec 29, 2024
1 parent 8443928 commit fe23e19
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
4 changes: 3 additions & 1 deletion src/modules/graphics/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Buffer::Buffer(Graphics *gfx, const Settings &settings, const std::vector<DataDe
if (info.baseType == DATA_BASETYPE_BOOL)
throw love::Exception("Bool types are not supported in vertex buffers.");

if (decl.bindingLocation < 0 || decl.bindingLocation >= VertexAttributes::MAX)
if (decl.bindingLocation < 0 || decl.bindingLocation >= (int) VertexAttributes::MAX)
{
if (decl.bindingLocation == -1 && !decl.name.empty())
legacyVertexBindings = true;
Expand Down Expand Up @@ -344,6 +344,8 @@ std::vector<Buffer::DataDeclaration> Buffer::getCommonFormatDeclaration(CommonFo
{ getConstant(ATTRIB_TEXCOORD), DATAFORMAT_FLOAT_VEC2, 0, ATTRIB_TEXCOORD },
{ getConstant(ATTRIB_COLOR), DATAFORMAT_UNORM8_VEC4, 0, ATTRIB_COLOR },
};
case CommonFormat::COUNT:
return {};
}

return {};
Expand Down
2 changes: 1 addition & 1 deletion src/modules/graphics/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void Mesh::finalizeAttribute(BufferAttribute &attrib) const
attrib.bindingLocation = (int)builtinattrib;
}

if (attrib.bindingLocation >= VertexAttributes::MAX || (attrib.bindingLocation < 0 && attrib.name.empty()))
if (attrib.bindingLocation >= (int) VertexAttributes::MAX || (attrib.bindingLocation < 0 && attrib.name.empty()))
throw love::Exception("Vertex attributes must have a valid binding location value within [0, %d).", VertexAttributes::MAX);
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/graphics/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ static bool AddFieldsToFormat(std::vector<Buffer::DataDeclaration> &format, int
DataFormat dataformat = getDataFormat(type->getBasicType(), type->getVectorSize(), type->getMatrixRows(), type->getMatrixCols(), type->isMatrix());
if (dataformat == DATAFORMAT_MAX_ENUM)
{
err = "Shader validation error:\nUnhandled data format for type " + (int)type->getBasicType() + std::string(" with name ") + basename;
err = "Shader validation error:\nUnhandled data format for type " + std::to_string((int)type->getBasicType()) + std::string(" with name ") + basename;
return false;
}

Expand Down
7 changes: 7 additions & 0 deletions src/modules/graphics/vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ size_t getFormatStride(CommonFormat format)
case CommonFormat::XYf_STf_RGBAub: return sizeof(XYf_STf_RGBAub);
case CommonFormat::XYf_STus_RGBAub: return sizeof(XYf_STus_RGBAub);
case CommonFormat::XYf_STPf_RGBAub: return sizeof(XYf_STPf_RGBAub);
case CommonFormat::COUNT: return 0;
}
return 0;
}
Expand All @@ -77,6 +78,8 @@ uint32 getFormatFlags(CommonFormat format)
case CommonFormat::XYf_STus_RGBAub:
case CommonFormat::XYf_STPf_RGBAub:
return ATTRIBFLAG_POS | ATTRIBFLAG_TEXCOORD | ATTRIBFLAG_COLOR;
case CommonFormat::COUNT:
return 0;
}
return 0;
}
Expand All @@ -99,6 +102,8 @@ int getFormatPositionComponents(CommonFormat format)
return 2;
case CommonFormat::XYZf:
return 3;
case CommonFormat::COUNT:
return 0;
}
return 0;
}
Expand Down Expand Up @@ -321,6 +326,8 @@ void VertexAttributes::setCommonFormat(CommonFormat format, uint8 bufferindex)
set(ATTRIB_TEXCOORD, DATAFORMAT_FLOAT_VEC3, uint16(sizeof(float) * 2), bufferindex);
set(ATTRIB_COLOR, DATAFORMAT_UNORM8_VEC4, uint16(sizeof(float) * 5), bufferindex);
break;
case CommonFormat::COUNT:
break;
}
}

Expand Down
21 changes: 9 additions & 12 deletions src/modules/physics/box2d/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ bool World::ContactFilter::process(Shape *a, Shape *b)
return true;
}

World::QueryCallback::QueryCallback(World *world, lua_State *L, int idx)
: world(world)
, L(L)
World::QueryCallback::QueryCallback(lua_State *L, int idx)
: L(L)
, funcidx(idx)
{
luaL_checktype(L, funcidx, LUA_TFUNCTION);
Expand Down Expand Up @@ -159,9 +158,8 @@ bool World::QueryCallback::ReportFixture(b2Fixture *fixture)
return true;
}

World::CollectCallback::CollectCallback(World *world, uint16 categoryMask, lua_State *L)
: world(world)
, categoryMask(categoryMask)
World::CollectCallback::CollectCallback(uint16 categoryMask, lua_State *L)
: categoryMask(categoryMask)
, L(L)
{
lua_newtable(L);
Expand All @@ -185,9 +183,8 @@ bool World::CollectCallback::ReportFixture(b2Fixture *f)
return true;
}

World::RayCastCallback::RayCastCallback(World *world, lua_State *L, int idx)
: world(world)
, L(L)
World::RayCastCallback::RayCastCallback(lua_State *L, int idx)
: L(L)
, funcidx(idx)
{
luaL_checktype(L, funcidx, LUA_TFUNCTION);
Expand Down Expand Up @@ -605,7 +602,7 @@ int World::queryShapesInArea(lua_State *L)
box.lowerBound = Physics::scaleDown(b2Vec2(lx, ly));
box.upperBound = Physics::scaleDown(b2Vec2(ux, uy));
luaL_checktype(L, 5, LUA_TFUNCTION);
QueryCallback query(this, L, 5);
QueryCallback query(L, 5);
world->QueryAABB(&query, box);
return 0;
}
Expand All @@ -620,7 +617,7 @@ int World::getShapesInArea(lua_State *L)
b2AABB box;
box.lowerBound = Physics::scaleDown(b2Vec2(lx, ly));
box.upperBound = Physics::scaleDown(b2Vec2(ux, uy));
CollectCallback query(this, categoryMaskBits, L);
CollectCallback query(categoryMaskBits, L);
world->QueryAABB(&query, box);
return 1;
}
Expand All @@ -634,7 +631,7 @@ int World::rayCast(lua_State *L)
b2Vec2 v1 = Physics::scaleDown(b2Vec2(x1, y1));
b2Vec2 v2 = Physics::scaleDown(b2Vec2(x2, y2));
luaL_checktype(L, 5, LUA_TFUNCTION);
RayCastCallback raycast(this, L, 5);
RayCastCallback raycast(L, 5);
world->RayCast(&raycast, v1, v2);
return 0;
}
Expand Down
9 changes: 3 additions & 6 deletions src/modules/physics/box2d/World.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,10 @@ class World : public Object, public b2ContactListener, public b2ContactFilter, p
class QueryCallback : public b2QueryCallback
{
public:
QueryCallback(World *world, lua_State *L, int idx);
QueryCallback(lua_State *L, int idx);
virtual ~QueryCallback();
bool ReportFixture(b2Fixture *fixture) override;
private:
World *world;
lua_State *L;
int funcidx;
int userargs;
Expand All @@ -106,11 +105,10 @@ class World : public Object, public b2ContactListener, public b2ContactFilter, p
class CollectCallback : public b2QueryCallback
{
public:
CollectCallback(World *world, uint16 categoryMask, lua_State *L);
CollectCallback(uint16 categoryMask, lua_State *L);
virtual ~CollectCallback();
bool ReportFixture(b2Fixture *fixture) override;
private:
World *world;
uint16 categoryMask;
lua_State *L;
int i = 1;
Expand All @@ -119,11 +117,10 @@ class World : public Object, public b2ContactListener, public b2ContactFilter, p
class RayCastCallback : public b2RayCastCallback
{
public:
RayCastCallback(World *world, lua_State *L, int idx);
RayCastCallback(lua_State *L, int idx);
virtual ~RayCastCallback();
float ReportFixture(b2Fixture *fixture, const b2Vec2 &point, const b2Vec2 &normal, float fraction) override;
private:
World *world;
lua_State *L;
int funcidx;
int userargs;
Expand Down

0 comments on commit fe23e19

Please sign in to comment.