From 9a15ca39988d7d32f0337e955a115fe22f762cf0 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sun, 14 Oct 2012 17:41:12 +0200 Subject: [PATCH 1/9] Update changelog a bit --- changes.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changes.txt b/changes.txt index ba05bd0d0..dc7752933 100644 --- a/changes.txt +++ b/changes.txt @@ -9,6 +9,7 @@ LOVE 0.8.1 [Rubber Piggy] * Added basic support for the file:// uri scheme. * Added love.mouse.setX/setY. * Added love.filesystem.getIdentity. + * Added HDR canvas support. * OPTIONAL: Added support for GME. * Fixed crashes with font drawing on some ATI cards. @@ -21,6 +22,10 @@ LOVE 0.8.1 [Rubber Piggy] * Fixed 'random' hangs in audio. * Fixed love.graphics.getLineWidth returning incorrect values. * Fixed possible memory leak in utf-8 decoder. + * Fixed love.sound.newDecoder not accepting FileData. + * Fixed multiplicative blend mode. + * Fixed Box2D exception in World:update. + * Fixed spacing for the last character in an ImageFont. * Moved love's startup to modules/love. @@ -32,6 +37,7 @@ LOVE 0.8.1 [Rubber Piggy] * Updated Source:set* functions to default z to 0. * Updated the windows console, it now tries to re-use an active one first. * Updated love.image memory handling, improves errors and thread-safety. + * Updated order of sleep/present in love.run (now draws, *then* sleeps). LOVE 0.8.0 [Rubber Piggy] ------------------------- From 6c850fdc98712b68517112960324b020bfaf0d56 Mon Sep 17 00:00:00 2001 From: vrld Date: Mon, 15 Oct 2012 17:13:08 +0200 Subject: [PATCH 2/9] Possibly (code in issue does not fail on my machine) fix #486. Please test. --- src/modules/graphics/opengl/VertexBuffer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/opengl/VertexBuffer.cpp b/src/modules/graphics/opengl/VertexBuffer.cpp index 720603bb0..098f3c883 100644 --- a/src/modules/graphics/opengl/VertexBuffer.cpp +++ b/src/modules/graphics/opengl/VertexBuffer.cpp @@ -139,9 +139,12 @@ void *VBO::map() void VBO::unmap() { - glBufferSubDataARB(getTarget(), 0, getSize(), mapped); - free(mapped); - mapped = 0; + if (mapped) + { + glBufferSubDataARB(getTarget(), 0, getSize(), mapped); + free(mapped); + mapped = 0; + } } void VBO::bind() From f3bf2bbfe528fd0f1bd6e282dacf60136f5f4ba9 Mon Sep 17 00:00:00 2001 From: vrld Date: Wed, 17 Oct 2012 18:36:32 +0200 Subject: [PATCH 3/9] Fix bug where the compat message crashed love. If in conf.lua `t.screen' is set to false or nil, the OpenGL context will not be initialized, leading to a crash in 'Font::print()' when printing the compat message later on. --- src/scripts/boot.lua | 5 +++-- src/scripts/boot.lua.h | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/scripts/boot.lua b/src/scripts/boot.lua index 095310504..5fed6e914 100644 --- a/src/scripts/boot.lua +++ b/src/scripts/boot.lua @@ -319,9 +319,10 @@ function love.init() end -- Setup screen here. + local has_window = false if c.screen and c.modules.graphics then if love.graphics.checkMode(c.screen.width, c.screen.height, c.screen.fullscreen) or (c.screen.width == 0 and c.screen.height == 0) then - assert(love.graphics.setMode(c.screen.width, c.screen.height, c.screen.fullscreen, c.screen.vsync, c.screen.fsaa), "Could not set screen mode") + has_window = assert(love.graphics.setMode(c.screen.width, c.screen.height, c.screen.fullscreen, c.screen.vsync, c.screen.fsaa), "Could not set screen mode") else error("Could not set screen mode") end @@ -364,7 +365,7 @@ function love.init() "The game might still work, but it is not guaranteed.\n" .. "Furthermore, this means one should not judge this game or the engine if not." print(msg) - if love.graphics and love.timer and love.event then + if has_window and love.timer and love.event then love.event.pump() love.graphics.setBackgroundColor(89, 157, 220) love.graphics.clear() diff --git a/src/scripts/boot.lua.h b/src/scripts/boot.lua.h index 8f47d5acf..9156b20f3 100644 --- a/src/scripts/boot.lua.h +++ b/src/scripts/boot.lua.h @@ -516,6 +516,8 @@ const unsigned char boot_lua[] = 0x09, 0x65, 0x6e, 0x64, 0x0a, 0x09, 0x2d, 0x2d, 0x20, 0x53, 0x65, 0x74, 0x75, 0x70, 0x20, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x68, 0x65, 0x72, 0x65, 0x2e, 0x0a, + 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x68, 0x61, 0x73, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x20, + 0x3d, 0x20, 0x66, 0x61, 0x6c, 0x73, 0x65, 0x0a, 0x09, 0x69, 0x66, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x63, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, @@ -527,15 +529,15 @@ const unsigned char boot_lua[] = 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2e, 0x77, 0x69, 0x64, 0x74, 0x68, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2e, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x20, 0x3d, 0x3d, 0x20, 0x30, 0x29, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, - 0x09, 0x09, 0x09, 0x61, 0x73, 0x73, 0x65, 0x72, 0x74, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, - 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x28, 0x63, 0x2e, 0x73, 0x63, - 0x72, 0x65, 0x65, 0x6e, 0x2e, 0x77, 0x69, 0x64, 0x74, 0x68, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, - 0x65, 0x6e, 0x2e, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, - 0x6e, 0x2e, 0x66, 0x75, 0x6c, 0x6c, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, - 0x72, 0x65, 0x65, 0x6e, 0x2e, 0x76, 0x73, 0x79, 0x6e, 0x63, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, - 0x65, 0x6e, 0x2e, 0x66, 0x73, 0x61, 0x61, 0x29, 0x2c, 0x20, 0x22, 0x43, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6e, - 0x6f, 0x74, 0x20, 0x73, 0x65, 0x74, 0x20, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x6d, 0x6f, 0x64, 0x65, - 0x22, 0x29, 0x0a, + 0x09, 0x09, 0x09, 0x68, 0x61, 0x73, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x20, 0x3d, 0x20, 0x61, 0x73, + 0x73, 0x65, 0x72, 0x74, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, + 0x2e, 0x73, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x28, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2e, + 0x77, 0x69, 0x64, 0x74, 0x68, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2e, 0x68, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2e, 0x66, 0x75, 0x6c, + 0x6c, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2e, + 0x76, 0x73, 0x79, 0x6e, 0x63, 0x2c, 0x20, 0x63, 0x2e, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x2e, 0x66, 0x73, + 0x61, 0x61, 0x29, 0x2c, 0x20, 0x22, 0x43, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x73, 0x65, + 0x74, 0x20, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x22, 0x29, 0x0a, 0x09, 0x09, 0x65, 0x6c, 0x73, 0x65, 0x0a, 0x09, 0x09, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x28, 0x22, 0x43, 0x6f, 0x75, 0x6c, 0x64, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x73, 0x65, 0x74, 0x20, 0x73, 0x63, 0x72, 0x65, 0x65, 0x6e, 0x20, 0x6d, 0x6f, 0x64, 0x65, 0x22, @@ -629,9 +631,9 @@ const unsigned char boot_lua[] = 0x20, 0x67, 0x61, 0x6d, 0x65, 0x20, 0x6f, 0x72, 0x20, 0x74, 0x68, 0x65, 0x20, 0x65, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x20, 0x69, 0x66, 0x20, 0x6e, 0x6f, 0x74, 0x2e, 0x22, 0x0a, 0x09, 0x09, 0x09, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x28, 0x6d, 0x73, 0x67, 0x29, 0x0a, - 0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, - 0x73, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x20, 0x61, - 0x6e, 0x64, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, + 0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x68, 0x61, 0x73, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x20, 0x61, + 0x6e, 0x64, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x74, 0x69, 0x6d, 0x65, 0x72, 0x20, 0x61, 0x6e, 0x64, 0x20, + 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x68, 0x65, 0x6e, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x75, 0x6d, 0x70, 0x28, 0x29, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, From 31f98ebf521560746a0f21de97f98928d2f0bf81 Mon Sep 17 00:00:00 2001 From: vrld Date: Thu, 18 Oct 2012 13:29:13 +0200 Subject: [PATCH 4/9] Fix #234 again. Of course this means the texture coordinates are flipped again... --- src/modules/graphics/opengl/Canvas.cpp | 32 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/src/modules/graphics/opengl/Canvas.cpp b/src/modules/graphics/opengl/Canvas.cpp index 72708f4a1..9119df4a8 100644 --- a/src/modules/graphics/opengl/Canvas.cpp +++ b/src/modules/graphics/opengl/Canvas.cpp @@ -304,13 +304,13 @@ Canvas::Canvas(int width, int height, TextureType texture_type) // texture coordinates vertices[0].s = 0; - vertices[0].t = 1; + vertices[0].t = 0; vertices[1].s = 0; - vertices[1].t = 0; + vertices[1].t = 1; vertices[2].s = 1; - vertices[2].t = 0; + vertices[2].t = 1; vertices[3].s = 1; - vertices[3].t = 1; + vertices[3].t = 0; getStrategy(); @@ -364,7 +364,7 @@ void Canvas::startGrab() glLoadIdentity(); // Set up orthographic view (no depth) - glOrtho(0.0, width, 0.0, height, -1.0, 1.0); + glOrtho(0.0, width, height, 0.0, -1.0, 1.0); // Switch back to modelview matrix glMatrixMode(GL_MODELVIEW); @@ -413,18 +413,26 @@ void Canvas::draw(float x, float y, float angle, float sx, float sy, float ox, f void Canvas::drawq(love::graphics::Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const { - static Matrix t; const vertex *v = quad->getVertices(); + // mirror quad on x axis + vertex w[4]; + memcpy(w, v, sizeof(vertex)*4); + for (size_t i = 0; i < 4; ++i) + w[i].t = 1. - w[i].t; + + static Matrix t; t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky); - drawv(t, v); + + drawv(t, w); } love::image::ImageData *Canvas::getImageData(love::image::Image *image) { int row = 4 * width; int size = row * height; - GLubyte *pixels = new GLubyte[size]; + GLubyte *pixels = new GLubyte[size]; + GLubyte *flipped = new GLubyte[size]; strategy->bindFBO(fbo); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); @@ -433,7 +441,13 @@ love::image::ImageData *Canvas::getImageData(love::image::Image *image) else strategy->bindFBO(0); - love::image::ImageData *img = image->newImageData(width, height, (void *)pixels); + GLubyte *src = pixels, *dst = flipped + size - row; + for (int i = 0; i < height; ++i, dst -= row, src += row) + { + memcpy(dst, src, row); + } + + love::image::ImageData *img = image->newImageData(width, height, (void *)flipped); delete[] pixels; From 2149ecdf44ef9db0c122c87481cc062056ef43e7 Mon Sep 17 00:00:00 2001 From: rude Date: Sun, 18 Nov 2012 10:53:17 +0100 Subject: [PATCH 5/9] Use "L" to force wide literal string. If multi-byte character set is chosen, TEXT() does not produce a wide string, causing compilation errors. --- src/modules/filesystem/physfs/Filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/filesystem/physfs/Filesystem.cpp b/src/modules/filesystem/physfs/Filesystem.cpp index 7f1efae06..a18827a92 100644 --- a/src/modules/filesystem/physfs/Filesystem.cpp +++ b/src/modules/filesystem/physfs/Filesystem.cpp @@ -236,7 +236,7 @@ const char *Filesystem::getAppdataDirectory() #ifdef LOVE_WINDOWS if (appdata.empty()) { - wchar_t *w_appdata = _wgetenv(TEXT("APPDATA")); + wchar_t *w_appdata = _wgetenv(L"APPDATA"); appdata = to_utf8(w_appdata); replace_char(appdata, '\\', '/'); } From 54498ce37886c3d23ebe5103b777d346d41f68ad Mon Sep 17 00:00:00 2001 From: rude Date: Sun, 18 Nov 2012 11:02:30 +0100 Subject: [PATCH 6/9] Apply slime73's ParticleSystem patch. --- .../graphics/opengl/ParticleSystem.cpp | 68 +++++++++++++++---- src/modules/graphics/opengl/ParticleSystem.h | 3 + 2 files changed, 59 insertions(+), 12 deletions(-) diff --git a/src/modules/graphics/opengl/ParticleSystem.cpp b/src/modules/graphics/opengl/ParticleSystem.cpp index 47e4b6552..167958dd7 100644 --- a/src/modules/graphics/opengl/ParticleSystem.cpp +++ b/src/modules/graphics/opengl/ParticleSystem.cpp @@ -62,6 +62,7 @@ ParticleSystem::ParticleSystem(Image *sprite, unsigned int buffer) : pStart(0) , pLast(0) , pEnd(0) + , particleVerts(0) , active(true) , emissionRate(0) , emitCounter(0) @@ -104,6 +105,9 @@ ParticleSystem::~ParticleSystem() if (pStart != 0) delete [] pStart; + + if (particleVerts != 0) + delete [] particleVerts; } void ParticleSystem::add() @@ -197,11 +201,18 @@ void ParticleSystem::setSprite(Image *image) void ParticleSystem::setBufferSize(unsigned int size) { // delete previous data - delete [] pStart; + if (pStart != 0) + delete [] pStart; pLast = pStart = new particle[size]; pEnd = pStart + size; + + if (particleVerts != 0) + delete [] particleVerts; + + // each particle has 4 vertices + particleVerts = new vertex[size*4]; } void ParticleSystem::setEmissionRate(int rate) @@ -457,25 +468,58 @@ bool ParticleSystem::isFull() const void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const { if (sprite == 0) return; // just in case of failure + + int numParticles = count(); + if (numParticles == 0) return; // don't bother if there's nothing to do glPushMatrix(); glPushAttrib(GL_CURRENT_BIT); - Matrix t; + static Matrix t; t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky); glMultMatrixf((const GLfloat *)t.getElements()); - - particle *p = pStart; - while (p != pLast) + + const vertex * imageVerts = sprite->getVertices(); + + // set the vertex data for each particle (transformation, texcoords, color) + for (int i = 0; i < numParticles; i++) { - glPushMatrix(); - - glColor4f(p->color.r, p->color.g, p->color.b, p->color.a); - sprite->draw(p->position[0], p->position[1], p->rotation, p->size, p->size, offsetX, offsetY, 0.0f, 0.0f); - - glPopMatrix(); - p++; + particle * p = pStart + i; + + // particle vertices are sprite vertices transformed by particle information + t.setTransformation(p->position[0], p->position[1], p->rotation, p->size, p->size, offsetX, offsetY, 0.0f, 0.0f); + t.transform(&particleVerts[i*4], &imageVerts[0], 4); + + // set the texture coordinate and color data for particle vertices + for (int v = 0; v < 4; v++) { + int vi = (i * 4) + v; // current vertex index for particle + + particleVerts[vi].s = imageVerts[v].s; + particleVerts[vi].t = imageVerts[v].t; + + // particle colors are stored as floats (0-1) but vertex colors are stored as unsigned bytes (0-255) + particleVerts[vi].r = p->color.r*255; + particleVerts[vi].g = p->color.g*255; + particleVerts[vi].b = p->color.b*255; + particleVerts[vi].a = p->color.a*255; + } } + + sprite->bind(); + + glEnableClientState(GL_COLOR_ARRAY); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + + glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *)&particleVerts[0].r); + glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].x); + glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid *)&particleVerts[0].s); + + glDrawArrays(GL_QUADS, 0, numParticles*4); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_COLOR_ARRAY); glPopAttrib(); glPopMatrix(); diff --git a/src/modules/graphics/opengl/ParticleSystem.h b/src/modules/graphics/opengl/ParticleSystem.h index 64cb5c519..5c02f75d7 100644 --- a/src/modules/graphics/opengl/ParticleSystem.h +++ b/src/modules/graphics/opengl/ParticleSystem.h @@ -406,6 +406,9 @@ protected: // Pointer to the end of the memory allocation. particle *pEnd; + + // array of transformed vertex data for all particles, for drawing + vertex * particleVerts; // The sprite to be drawn. Image *sprite; From 94516e22904ad47f1b6179208c323a7477ec8e9e Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sun, 18 Nov 2012 18:48:37 +0100 Subject: [PATCH 7/9] Catch possible exceptions thrown when locking a SpriteBatch twice --- src/modules/graphics/opengl/wrap_SpriteBatch.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index 470ba9947..513f367d6 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -112,7 +112,14 @@ int w_SpriteBatch_clear(lua_State *L) int w_SpriteBatch_bind(lua_State *L) { SpriteBatch *t = luax_checkspritebatch(L, 1); - t->lock(); + try + { + t->lock(); + } + catch (love::Exception &e) + { + return luaL_error(L, "%s", e.what()); + } return 0; } From 3a47bafd414e08e0af487b7342a8a378516c0430 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sun, 18 Nov 2012 19:01:51 +0100 Subject: [PATCH 8/9] Add Source:isPlaying --- src/modules/audio/wrap_Source.cpp | 8 ++++++++ src/modules/audio/wrap_Source.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/modules/audio/wrap_Source.cpp b/src/modules/audio/wrap_Source.cpp index 1795dec0e..554d71eff 100644 --- a/src/modules/audio/wrap_Source.cpp +++ b/src/modules/audio/wrap_Source.cpp @@ -210,6 +210,13 @@ int w_Source_isPaused(lua_State *L) return 1; } +int w_Source_isPlaying(lua_State *L) +{ + Source *t = luax_checksource(L, 1); + luax_pushboolean(L, !t->isStopped() && !t->isPaused()); + return 1; +} + int w_Source_isStatic(lua_State *L) { Source *t = luax_checksource(L, 1); @@ -299,6 +306,7 @@ static const luaL_Reg functions[] = { "isLooping", w_Source_isLooping }, { "isStopped", w_Source_isStopped }, { "isPaused", w_Source_isPaused }, + { "isPlaying", w_Source_isPlaying }, { "isStatic", w_Source_isStatic }, { "setVolumeLimits", w_Source_setVolumeLimits }, diff --git a/src/modules/audio/wrap_Source.h b/src/modules/audio/wrap_Source.h index b9fff3953..a62010bf6 100644 --- a/src/modules/audio/wrap_Source.h +++ b/src/modules/audio/wrap_Source.h @@ -51,6 +51,7 @@ int w_Source_setLooping(lua_State *L); int w_Source_isLooping(lua_State *L); int w_Source_isStopped(lua_State *L); int w_Source_isPaused(lua_State *L); +int w_Source_isPlaying(lua_State *L); int w_Source_isStatic(lua_State *L); int w_Source_setVolumeLimits(lua_State *L); int w_Source_getVolumeLimits(lua_State *L); From d24c0344c8840bb1f94f1513de9c4a72209b3563 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sun, 18 Nov 2012 19:18:37 +0100 Subject: [PATCH 9/9] Make second argument to setDefaultImageFilter Image:setFilter and Image:setWrap optional, and default to the first --- src/modules/graphics/opengl/wrap_Graphics.cpp | 2 +- src/modules/graphics/opengl/wrap_Image.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 44506307f..cd87f2e3e 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -589,7 +589,7 @@ int w_setDefaultImageFilter(lua_State *L) Image::FilterMode min; Image::FilterMode mag; const char *minstr = luaL_checkstring(L, 1); - const char *magstr = luaL_checkstring(L, 2); + const char *magstr = luaL_optstring(L, 2, minstr); if (!Image::getConstant(minstr, min)) return luaL_error(L, "Invalid filter mode: %s", minstr); if (!Image::getConstant(magstr, mag)) diff --git a/src/modules/graphics/opengl/wrap_Image.cpp b/src/modules/graphics/opengl/wrap_Image.cpp index fa09f000d..af40f3add 100644 --- a/src/modules/graphics/opengl/wrap_Image.cpp +++ b/src/modules/graphics/opengl/wrap_Image.cpp @@ -54,7 +54,7 @@ int w_Image_setFilter(lua_State *L) Image::FilterMode min; Image::FilterMode mag; const char *minstr = luaL_checkstring(L, 2); - const char *magstr = luaL_checkstring(L, 3); + const char *magstr = luaL_optstring(L, 3, minstr); if (!Image::getConstant(minstr, min)) return luaL_error(L, "Invalid filter mode: %s", minstr); if (!Image::getConstant(magstr, mag)) @@ -88,7 +88,7 @@ int w_Image_setWrap(lua_State *L) Image::WrapMode s; Image::WrapMode t; const char *sstr = luaL_checkstring(L, 2); - const char *tstr = luaL_checkstring(L, 3); + const char *tstr = luaL_optstring(L, 3, sstr); if (!Image::getConstant(sstr, s)) return luaL_error(L, "Invalid wrap mode: %s", sstr); if (!Image::getConstant(tstr, t))