diff --git a/src/modules/audio/Source.h b/src/modules/audio/Source.h index da74a47dd..b7f97f955 100644 --- a/src/modules/audio/Source.h +++ b/src/modules/audio/Source.h @@ -103,7 +103,7 @@ public: virtual int getChannels() const = 0; virtual int getFreeBufferCount() const = 0; - virtual bool queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels) = 0; + virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels) = 0; virtual Type getType() const; diff --git a/src/modules/audio/null/Source.cpp b/src/modules/audio/null/Source.cpp index c74a522f0..4fca8ac4a 100644 --- a/src/modules/audio/null/Source.cpp +++ b/src/modules/audio/null/Source.cpp @@ -222,7 +222,7 @@ int Source::getFreeBufferCount() const return 0; } -bool Source::queue(void *, int, int, int, int) +bool Source::queue(void *, size_t, int, int, int) { return false; } diff --git a/src/modules/audio/null/Source.h b/src/modules/audio/null/Source.h index 780c39453..6e930123f 100644 --- a/src/modules/audio/null/Source.h +++ b/src/modules/audio/null/Source.h @@ -77,7 +77,7 @@ public: virtual int getChannels() const; virtual int getFreeBufferCount() const; - virtual bool queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels); + virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels); private: diff --git a/src/modules/audio/openal/Source.cpp b/src/modules/audio/openal/Source.cpp index 1de16979e..47169c583 100644 --- a/src/modules/audio/openal/Source.cpp +++ b/src/modules/audio/openal/Source.cpp @@ -663,7 +663,7 @@ bool Source::isLooping() const return looping; } -bool Source::queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels) +bool Source::queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels) { if (type != TYPE_QUEUE) throw QueueTypeMismatchException(); @@ -883,7 +883,7 @@ bool Source::playAtomic(const std::vector &sources, const } alGetError(); - alSourcePlayv(toPlay.size(), &toPlay[0]); + alSourcePlayv((ALsizei) toPlay.size(), &toPlay[0]); bool success = alGetError() == AL_NO_ERROR; for (auto &_source : sources) @@ -912,7 +912,7 @@ void Source::stopAtomic(const std::vector &sources) sourceIds.push_back(source->source); } - alSourceStopv(sources.size(), &sourceIds[0]); + alSourceStopv((ALsizei) sources.size(), &sourceIds[0]); for (auto &_source : sources) { @@ -936,7 +936,7 @@ void Source::pauseAtomic(const std::vector &sources) sourceIds.push_back(source->source); } - alSourcePausev(sources.size(), &sourceIds[0]); + alSourcePausev((ALsizei) sources.size(), &sourceIds[0]); } void Source::reset() diff --git a/src/modules/audio/openal/Source.h b/src/modules/audio/openal/Source.h index c5b42fe25..9bddfb73d 100644 --- a/src/modules/audio/openal/Source.h +++ b/src/modules/audio/openal/Source.h @@ -142,7 +142,7 @@ public: virtual int getChannels() const; virtual int getFreeBufferCount() const; - virtual bool queue(void *data, int length, int dataSampleRate, int dataBitDepth, int dataChannels); + virtual bool queue(void *data, size_t length, int dataSampleRate, int dataBitDepth, int dataChannels); virtual bool queueAtomic(void *data, ALsizei length); void prepareAtomic(); diff --git a/src/modules/audio/wrap_Audio.cpp b/src/modules/audio/wrap_Audio.cpp index e447467bf..7a178abc8 100644 --- a/src/modules/audio/wrap_Audio.cpp +++ b/src/modules/audio/wrap_Audio.cpp @@ -101,10 +101,10 @@ static std::vector readSourceList(lua_State *L, int n) if (n < 0) n += lua_gettop(L) + 1; - size_t items = lua_objlen(L, n); + int items = (int) lua_objlen(L, n); std::vector sources(items); - for (size_t i = 0; i < items; i++) + for (int i = 0; i < items; i++) { lua_rawgeti(L, n, i+1); sources[i] = luax_checksource(L, -1); @@ -147,8 +147,8 @@ int w_pause(lua_State *L) { auto sources = instance()->pause(); - lua_createtable(L, sources.size(), 0); - for (size_t i = 0; i < sources.size(); i++) + lua_createtable(L, (int) sources.size(), 0); + for (int i = 0; i < (int) sources.size(); i++) { luax_pushtype(L, AUDIO_SOURCE_ID, sources[i]); lua_rawseti(L, -2, i+1); diff --git a/src/modules/audio/wrap_Source.cpp b/src/modules/audio/wrap_Source.cpp index 9abbb457b..35e9f3c91 100644 --- a/src/modules/audio/wrap_Source.cpp +++ b/src/modules/audio/wrap_Source.cpp @@ -344,10 +344,10 @@ int w_Source_queue(lua_State *L) if (luax_istype(L, 2, SOUND_SOUND_DATA_ID)) { - love::sound::SoundData *s = luax_totype(L, 2, SOUND_SOUND_DATA_ID); + auto s = luax_totype(L, 2, SOUND_SOUND_DATA_ID); int offset = 0; - int length = s->getSize(); + size_t length = s->getSize(); if (lua_gettop(L) == 4) { @@ -357,12 +357,12 @@ int w_Source_queue(lua_State *L) else if (lua_gettop(L) == 3) length = luaL_checknumber(L, 3); - if (length > (int)s->getSize() - offset || offset < 0 || length < 0) + if (offset < 0 || length > s->getSize() - offset) return luaL_error(L, "Data region out of bounds."); luax_catchexcept(L, [&]() { - success = t->queue((void*)((uintptr_t)s->getData() + (uintptr_t)offset), - length, s->getSampleRate(), s->getBitDepth(), s->getChannels()); + success = t->queue((unsigned char *)s->getData() + offset, length, + s->getSampleRate(), s->getBitDepth(), s->getChannels()); }); } else if (lua_islightuserdata(L, 2)) diff --git a/src/modules/font/freetype/TrueTypeRasterizer.cpp b/src/modules/font/freetype/TrueTypeRasterizer.cpp index 1c67ef00f..55caf0e2a 100644 --- a/src/modules/font/freetype/TrueTypeRasterizer.cpp +++ b/src/modules/font/freetype/TrueTypeRasterizer.cpp @@ -76,7 +76,7 @@ GlyphData *TrueTypeRasterizer::getGlyphData(uint32 glyph) const FT_Glyph ftglyph; FT_Error err = FT_Err_Ok; - FT_ULong loadoption = hintingToLoadOption(hinting); + FT_UInt loadoption = hintingToLoadOption(hinting); // Initialize err = FT_Load_Glyph(face, FT_Get_Char_Index(face, glyph), FT_LOAD_DEFAULT | loadoption); @@ -185,7 +185,7 @@ bool TrueTypeRasterizer::accepts(FT_Library library, love::Data *data) return FT_New_Memory_Face(library, fbase, fsize, -1, nullptr) == 0; } -FT_ULong TrueTypeRasterizer::hintingToLoadOption(Hinting hint) +FT_UInt TrueTypeRasterizer::hintingToLoadOption(Hinting hint) { switch (hint) { diff --git a/src/modules/font/freetype/TrueTypeRasterizer.h b/src/modules/font/freetype/TrueTypeRasterizer.h index 3e07bcc0f..c8247fa86 100644 --- a/src/modules/font/freetype/TrueTypeRasterizer.h +++ b/src/modules/font/freetype/TrueTypeRasterizer.h @@ -58,7 +58,7 @@ public: private: - static FT_ULong hintingToLoadOption(Hinting hinting); + static FT_UInt hintingToLoadOption(Hinting hinting); // TrueType face FT_Face face; diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 4e79a766a..55268b16b 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -629,7 +629,7 @@ love::image::ImageData *Canvas::newImageData(love::image::Image *image, int x, i break; } - int size = w * h * image::ImageData::getPixelSize(imageformat); + size_t size = w * h * image::ImageData::getPixelSize(imageformat); uint8 *pixels = nullptr; try { diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 5732fe847..7c5c68ae8 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -1299,7 +1299,7 @@ void Graphics::points(const float *coords, const uint8 *colors, size_t numpoints } gl.useVertexAttribArrays(attribflags); - gl.drawArrays(GL_POINTS, 0, numpoints); + gl.drawArrays(GL_POINTS, 0, (GLsizei) numpoints); } void Graphics::polyline(const float *coords, size_t count) diff --git a/src/modules/graphics/opengl/Mesh.cpp b/src/modules/graphics/opengl/Mesh.cpp index 0a77c58b4..a8cc0a688 100644 --- a/src/modules/graphics/opengl/Mesh.cpp +++ b/src/modules/graphics/opengl/Mesh.cpp @@ -569,7 +569,7 @@ int Mesh::bindAttributeToShaderInput(int attributeindex, const std::string &inpu GLenum datatype = getGLDataType(format.type); GLboolean normalized = (datatype == GL_UNSIGNED_BYTE); - glVertexAttribPointer(attriblocation, format.components, datatype, normalized, vertexStride, gloffset); + glVertexAttribPointer(attriblocation, format.components, datatype, normalized, (GLsizei) vertexStride, gloffset); return attriblocation; } diff --git a/src/modules/graphics/opengl/Shader.cpp b/src/modules/graphics/opengl/Shader.cpp index cfa52c9ac..4696becb8 100644 --- a/src/modules/graphics/opengl/Shader.cpp +++ b/src/modules/graphics/opengl/Shader.cpp @@ -420,7 +420,7 @@ void Shader::attach(bool temporary) { // make sure all sent textures are properly bound to their respective texture units // note: list potentially contains texture ids of deleted/invalid textures! - for (size_t i = 0; i < activeTexUnits.size(); ++i) + for (int i = 0; i < (int) activeTexUnits.size(); ++i) { if (activeTexUnits[i] > 0) gl.bindTextureToUnit(activeTexUnits[i], i + 1, false); diff --git a/src/modules/graphics/opengl/wrap_Mesh.cpp b/src/modules/graphics/opengl/wrap_Mesh.cpp index 1db25874c..3f730554a 100644 --- a/src/modules/graphics/opengl/wrap_Mesh.cpp +++ b/src/modules/graphics/opengl/wrap_Mesh.cpp @@ -131,7 +131,7 @@ int w_Mesh_setVertices(lua_State *L) } luaL_checktype(L, 2, LUA_TTABLE); - size_t nvertices = luax_objlen(L, 2); + int nvertices = (int) luax_objlen(L, 2); if (vertoffset + nvertices > t->getVertexCount()) return luaL_error(L, "Too many vertices (expected at most %d, got %d)", (int) t->getVertexCount() - (int) vertoffset, (int) nvertices); @@ -144,7 +144,7 @@ int w_Mesh_setVertices(lua_State *L) char *data = (char *) t->mapVertexData() + byteoffset; - for (size_t i = 0; i < nvertices; i++) + for (int i = 0; i < nvertices; i++) { // get vertices[vertindex] lua_rawgeti(L, 2, i + 1); diff --git a/src/modules/graphics/opengl/wrap_Text.cpp b/src/modules/graphics/opengl/wrap_Text.cpp index bd365e9a6..793b7ad11 100644 --- a/src/modules/graphics/opengl/wrap_Text.cpp +++ b/src/modules/graphics/opengl/wrap_Text.cpp @@ -39,7 +39,7 @@ void luax_checkcoloredstring(lua_State *L, int idx, std::vector BezierCurve::render(int accuracy) const return vertices; } -vector BezierCurve::renderSegment(double start, double end, size_t accuracy) const +vector BezierCurve::renderSegment(double start, double end, int accuracy) const { if (controlPoints.size() < 2) throw Exception("Invalid Bezier curve: Not enough control points."); diff --git a/src/modules/math/BezierCurve.h b/src/modules/math/BezierCurve.h index 960676bb7..76d52d508 100644 --- a/src/modules/math/BezierCurve.h +++ b/src/modules/math/BezierCurve.h @@ -136,7 +136,7 @@ public: * @param accuracy The 'fineness' of the curve. * @returns A polygon chain that approximates the segment along the curve **/ - std::vector renderSegment(double start, double end, size_t accuracy = 4) const; + std::vector renderSegment(double start, double end, int accuracy = 4) const; private: std::vector controlPoints; diff --git a/src/modules/math/Compressor.cpp b/src/modules/math/Compressor.cpp index 513fe9b8b..ea68e4704 100644 --- a/src/modules/math/Compressor.cpp +++ b/src/modules/math/Compressor.cpp @@ -146,7 +146,7 @@ public: { // Account for our custom header's size in the decompress arguments. int result = LZ4_decompress_safe(data + headersize, rawbytes, - dataSize - headersize, rawsize); + (int) (dataSize - headersize), rawsize); if (result < 0) { diff --git a/src/modules/math/wrap_BezierCurve.cpp b/src/modules/math/wrap_BezierCurve.cpp index 1133a9de8..ab6994eb5 100644 --- a/src/modules/math/wrap_BezierCurve.cpp +++ b/src/modules/math/wrap_BezierCurve.cpp @@ -196,13 +196,13 @@ int w_BezierCurve_renderSegment(lua_State *L) BezierCurve *curve = luax_checkbeziercurve(L, 1); double start = luaL_checknumber(L, 2); double end = luaL_checknumber(L, 3); - int accuracy = luaL_optinteger(L, 4, 5); + int accuracy = (int) luaL_optnumber(L, 4, 5); std::vector points; luax_catchexcept(L, [&](){ points = curve->renderSegment(start, end, accuracy); }); - lua_createtable(L, points.size()*2, 0); - for (size_t i = 0; i < points.size(); ++i) + lua_createtable(L, (int) points.size() * 2, 0); + for (int i = 0; i < (int) points.size(); ++i) { lua_pushnumber(L, points[i].x); lua_rawseti(L, -2, 2*i+1); diff --git a/src/modules/sound/lullaby/ModPlugDecoder.cpp b/src/modules/sound/lullaby/ModPlugDecoder.cpp index fdec2b29b..12c43ecf6 100644 --- a/src/modules/sound/lullaby/ModPlugDecoder.cpp +++ b/src/modules/sound/lullaby/ModPlugDecoder.cpp @@ -61,7 +61,7 @@ ModPlugDecoder::ModPlugDecoder(Data *data, const std::string &ext, int bufferSiz ModPlug_SetSettings(&settings); // Load the module. - plug = ModPlug_Load(data->getData(), data->getSize()); + plug = ModPlug_Load(data->getData(), (int) data->getSize()); if (plug == 0) throw love::Exception("Could not load file with ModPlug."); @@ -121,7 +121,7 @@ bool ModPlugDecoder::rewind() { // Let's reload. ModPlug_Unload(plug); - plug = ModPlug_Load(data->getData(), data->getSize()); + plug = ModPlug_Load(data->getData(), (int) data->getSize()); ModPlug_SetMasterVolume(plug, 128); eof = false; return (plug != 0); diff --git a/src/modules/sound/lullaby/Mpg123Decoder.cpp b/src/modules/sound/lullaby/Mpg123Decoder.cpp index af4d22e5e..45e113fc8 100644 --- a/src/modules/sound/lullaby/Mpg123Decoder.cpp +++ b/src/modules/sound/lullaby/Mpg123Decoder.cpp @@ -157,7 +157,7 @@ Mpg123Decoder::Mpg123Decoder(Data *data, const std::string &ext, int bufferSize) mpg123_format_none(handle); mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16); - sampleRate = rate; + sampleRate = (int) rate; } catch (love::Exception &) { diff --git a/src/modules/sound/lullaby/VorbisDecoder.cpp b/src/modules/sound/lullaby/VorbisDecoder.cpp index b9461439f..31a2fc975 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.cpp +++ b/src/modules/sound/lullaby/VorbisDecoder.cpp @@ -76,9 +76,9 @@ static int vorbisSeek(void *datasource /* ptr to the data that the vorbis files ogg_int64_t offset /*offset from the point we wish to seek to*/, int whence /*where we want to seek to*/) { - int spaceToEOF; // How much more we can read till we hit the EOF marker - ogg_int64_t actualOffset; // How much we can actually offset it by - SOggFile *vorbisData; // The data we passed in (for the typecast) + int64 spaceToEOF; // How much more we can read till we hit the EOF marker + int64 actualOffset; // How much we can actually offset it by + SOggFile *vorbisData; // The data we passed in (for the typecast) // Get the data in the right format vorbisData = (SOggFile *) datasource; @@ -103,7 +103,7 @@ static int vorbisSeek(void *datasource /* ptr to the data that the vorbis files else actualOffset = spaceToEOF; // Seek from our currrent location - vorbisData->dataRead += (int)actualOffset; + vorbisData->dataRead += actualOffset; break; case SEEK_END: // Seek from the end of the file if (offset < 0) @@ -147,7 +147,7 @@ VorbisDecoder::VorbisDecoder(Data *data, const std::string &ext, int bufferSize) // Initialize OGG file oggFile.dataPtr = (const char *) data->getData(); - oggFile.dataSize = (int) data->getSize(); + oggFile.dataSize = data->getSize(); oggFile.dataRead = 0; // Open Vorbis handle diff --git a/src/modules/sound/lullaby/VorbisDecoder.h b/src/modules/sound/lullaby/VorbisDecoder.h index c34d14676..458888e7a 100644 --- a/src/modules/sound/lullaby/VorbisDecoder.h +++ b/src/modules/sound/lullaby/VorbisDecoder.h @@ -23,6 +23,7 @@ // LOVE #include "common/Data.h" +#include "common/int.h" #include "Decoder.h" // vorbis @@ -41,8 +42,8 @@ namespace lullaby struct SOggFile { const char *dataPtr; // Pointer to the data in memory - int dataSize; // Size of the data - int dataRead; // How much we've read so far + int64 dataSize; // Size of the data + int64 dataRead; // How much we've read so far }; class VorbisDecoder : public Decoder