mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Merge
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
A9255F461043247300BA1496 /* IL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F421043240F00BA1496 /* IL.framework */; };
|
A9255F461043247300BA1496 /* IL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F421043240F00BA1496 /* IL.framework */; };
|
||||||
A9255F52104324D700BA1496 /* Ogg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F51104324D700BA1496 /* Ogg.framework */; };
|
A9255F52104324D700BA1496 /* Ogg.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F51104324D700BA1496 /* Ogg.framework */; };
|
||||||
A9255F58104324E100BA1496 /* Ogg.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F51104324D700BA1496 /* Ogg.framework */; };
|
A9255F58104324E100BA1496 /* Ogg.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = A9255F51104324D700BA1496 /* Ogg.framework */; };
|
||||||
|
A93A3AB51121E86E003B04A4 /* Image.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A93A3AB41121E86E003B04A4 /* Image.cpp */; };
|
||||||
A93E6E4910420B4A007D418B /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E4610420B4A007D418B /* OpenAL.framework */; };
|
A93E6E4910420B4A007D418B /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E4610420B4A007D418B /* OpenAL.framework */; };
|
||||||
A93E6E4A10420B4A007D418B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E4710420B4A007D418B /* OpenGL.framework */; };
|
A93E6E4A10420B4A007D418B /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E4710420B4A007D418B /* OpenGL.framework */; };
|
||||||
A93E6E4B10420B4A007D418B /* FreeType.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E4810420B4A007D418B /* FreeType.framework */; };
|
A93E6E4B10420B4A007D418B /* FreeType.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A93E6E4810420B4A007D418B /* FreeType.framework */; };
|
||||||
@@ -225,6 +226,7 @@
|
|||||||
A9255E021043195A00BA1496 /* Vorbis.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Vorbis.framework; path = /Library/Frameworks/Vorbis.framework; sourceTree = "<absolute>"; };
|
A9255E021043195A00BA1496 /* Vorbis.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Vorbis.framework; path = /Library/Frameworks/Vorbis.framework; sourceTree = "<absolute>"; };
|
||||||
A9255F421043240F00BA1496 /* IL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IL.framework; path = /Library/Frameworks/IL.framework; sourceTree = "<absolute>"; };
|
A9255F421043240F00BA1496 /* IL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IL.framework; path = /Library/Frameworks/IL.framework; sourceTree = "<absolute>"; };
|
||||||
A9255F51104324D700BA1496 /* Ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Ogg.framework; path = /Library/Frameworks/Ogg.framework; sourceTree = "<absolute>"; };
|
A9255F51104324D700BA1496 /* Ogg.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Ogg.framework; path = /Library/Frameworks/Ogg.framework; sourceTree = "<absolute>"; };
|
||||||
|
A93A3AB41121E86E003B04A4 /* Image.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Image.cpp; sourceTree = "<group>"; };
|
||||||
A93E69DE10420ABF007D418B /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
A93E69DE10420ABF007D418B /* config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config.h; sourceTree = "<group>"; };
|
||||||
A93E69DF10420ABF007D418B /* Data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Data.h; sourceTree = "<group>"; };
|
A93E69DF10420ABF007D418B /* Data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Data.h; sourceTree = "<group>"; };
|
||||||
A93E69E010420ABF007D418B /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Exception.cpp; sourceTree = "<group>"; };
|
A93E69E010420ABF007D418B /* Exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Exception.cpp; sourceTree = "<group>"; };
|
||||||
@@ -560,9 +562,9 @@
|
|||||||
A93E6B9210420ACC007D418B /* wrap_Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Timer.h; sourceTree = "<group>"; };
|
A93E6B9210420ACC007D418B /* wrap_Timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Timer.h; sourceTree = "<group>"; };
|
||||||
A93E6B9410420ACC007D418B /* resources.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = resources.cpp; sourceTree = "<group>"; };
|
A93E6B9410420ACC007D418B /* resources.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = resources.cpp; sourceTree = "<group>"; };
|
||||||
A93E6B9510420ACC007D418B /* resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resources.h; sourceTree = "<group>"; };
|
A93E6B9510420ACC007D418B /* resources.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resources.h; sourceTree = "<group>"; };
|
||||||
A93E6B9710420ACC007D418B /* boot.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = boot.lua; sourceTree = "<group>"; };
|
A93E6B9710420ACC007D418B /* boot.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lua; path = boot.lua; sourceTree = "<group>"; };
|
||||||
A93E6B9810420ACC007D418B /* boot.lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = boot.lua.h; sourceTree = "<group>"; };
|
A93E6B9810420ACC007D418B /* boot.lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = boot.lua.h; sourceTree = "<group>"; };
|
||||||
A93E6B9910420ACC007D418B /* graphics.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = graphics.lua; sourceTree = "<group>"; };
|
A93E6B9910420ACC007D418B /* graphics.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lua; path = graphics.lua; sourceTree = "<group>"; };
|
||||||
A93E6B9A10420ACC007D418B /* graphics.lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = graphics.lua.h; sourceTree = "<group>"; };
|
A93E6B9A10420ACC007D418B /* graphics.lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = graphics.lua.h; sourceTree = "<group>"; };
|
||||||
A93E6E4610420B4A007D418B /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
|
A93E6E4610420B4A007D418B /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; };
|
||||||
A93E6E4710420B4A007D418B /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
|
A93E6E4710420B4A007D418B /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
|
||||||
@@ -592,6 +594,8 @@
|
|||||||
A9DEC1C01046EFA70049C70C /* LoveDocument.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = LoveDocument.icns; path = icons/LoveDocument.icns; sourceTree = "<group>"; };
|
A9DEC1C01046EFA70049C70C /* LoveDocument.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; name = LoveDocument.icns; path = icons/LoveDocument.icns; sourceTree = "<group>"; };
|
||||||
A9F16926109E7BAD00FC83D1 /* libmodplug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libmodplug.framework; path = /Library/Frameworks/libmodplug.framework; sourceTree = "<absolute>"; };
|
A9F16926109E7BAD00FC83D1 /* libmodplug.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libmodplug.framework; path = /Library/Frameworks/libmodplug.framework; sourceTree = "<absolute>"; };
|
||||||
A9F169A6109E824900FC83D1 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = "<absolute>"; };
|
A9F169A6109E824900FC83D1 /* mpg123.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mpg123.framework; path = /Library/Frameworks/mpg123.framework; sourceTree = "<absolute>"; };
|
||||||
|
A9F8833511163C8C00831E98 /* audio.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.lua; path = audio.lua; sourceTree = "<group>"; };
|
||||||
|
A9F8833611163C8C00831E98 /* audio.lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = audio.lua.h; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -948,6 +952,7 @@
|
|||||||
A93E6A8310420AC2007D418B /* Drawable.h */,
|
A93E6A8310420AC2007D418B /* Drawable.h */,
|
||||||
A968F0D21083A9D400A895AA /* Graphics.cpp */,
|
A968F0D21083A9D400A895AA /* Graphics.cpp */,
|
||||||
A93E6A8410420AC2007D418B /* Graphics.h */,
|
A93E6A8410420AC2007D418B /* Graphics.h */,
|
||||||
|
A93A3AB41121E86E003B04A4 /* Image.cpp */,
|
||||||
A93E6A8510420AC2007D418B /* Image.h */,
|
A93E6A8510420AC2007D418B /* Image.h */,
|
||||||
A93E6A8610420AC2007D418B /* opengl */,
|
A93E6A8610420AC2007D418B /* opengl */,
|
||||||
A93E6AA510420AC3007D418B /* Volatile.cpp */,
|
A93E6AA510420AC3007D418B /* Volatile.cpp */,
|
||||||
@@ -1001,8 +1006,8 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
A93E6AA810420AC3007D418B /* devil */,
|
A93E6AA810420AC3007D418B /* devil */,
|
||||||
A98D913E10507BF9008E03F2 /* EncodedImageData.h */,
|
|
||||||
A98D914310507C97008E03F2 /* EncodedImageData.cpp */,
|
A98D914310507C97008E03F2 /* EncodedImageData.cpp */,
|
||||||
|
A98D913E10507BF9008E03F2 /* EncodedImageData.h */,
|
||||||
A93E6AAD10420AC3007D418B /* Image.h */,
|
A93E6AAD10420AC3007D418B /* Image.h */,
|
||||||
A93E6AAE10420AC3007D418B /* ImageData.cpp */,
|
A93E6AAE10420AC3007D418B /* ImageData.cpp */,
|
||||||
A93E6AAF10420AC3007D418B /* ImageData.h */,
|
A93E6AAF10420AC3007D418B /* ImageData.h */,
|
||||||
@@ -1368,6 +1373,8 @@
|
|||||||
A93E6B9610420ACC007D418B /* scripts */ = {
|
A93E6B9610420ACC007D418B /* scripts */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
A9F8833511163C8C00831E98 /* audio.lua */,
|
||||||
|
A9F8833611163C8C00831E98 /* audio.lua.h */,
|
||||||
A93E6B9710420ACC007D418B /* boot.lua */,
|
A93E6B9710420ACC007D418B /* boot.lua */,
|
||||||
A93E6B9810420ACC007D418B /* boot.lua.h */,
|
A93E6B9810420ACC007D418B /* boot.lua.h */,
|
||||||
A93E6B9910420ACC007D418B /* graphics.lua */,
|
A93E6B9910420ACC007D418B /* graphics.lua */,
|
||||||
@@ -1612,6 +1619,7 @@
|
|||||||
A968F0DD1083AA6600A895AA /* Shape.cpp in Sources */,
|
A968F0DD1083AA6600A895AA /* Shape.cpp in Sources */,
|
||||||
A968F0DE1083AA6600A895AA /* Joint.cpp in Sources */,
|
A968F0DE1083AA6600A895AA /* Joint.cpp in Sources */,
|
||||||
A9CF0E8610B9EB1000E6F37E /* utf8.cpp in Sources */,
|
A9CF0E8610B9EB1000E6F37E /* utf8.cpp in Sources */,
|
||||||
|
A93A3AB51121E86E003B04A4 /* Image.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
+33
-33
@@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
* claim that you wrote the original software. If you use this software
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef LOVE_STRING_MAP_H
|
#ifndef LOVE_STRING_MAP_H
|
||||||
@@ -65,8 +65,8 @@ namespace love
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool streq(const char * a, const char * b)
|
bool streq(const char * a, const char * b)
|
||||||
{
|
{
|
||||||
while(*a != 0 && *b != 0)
|
while(*a != 0 && *b != 0)
|
||||||
{
|
{
|
||||||
if(*a != *b)
|
if(*a != *b)
|
||||||
@@ -75,16 +75,16 @@ namespace love
|
|||||||
++b;
|
++b;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (*a == 0 && *b == 0);
|
return (*a == 0 && *b == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool find(const char * key, T & t)
|
bool find(const char * key, T & t)
|
||||||
{
|
{
|
||||||
unsigned str_hash = djb2(key);
|
//unsigned str_hash = djb2(key);
|
||||||
|
|
||||||
for(unsigned i = 0; i < MAX; ++i)
|
for(unsigned i = 0; i < MAX; ++i)
|
||||||
{
|
{
|
||||||
unsigned str_i = (str_hash + i) % MAX;
|
//unsigned str_i = (str_hash + i) % MAX; //this isn't used, is this intentional?
|
||||||
|
|
||||||
if(records[i].set && streq(records[i].key, key))
|
if(records[i].set && streq(records[i].key, key))
|
||||||
{
|
{
|
||||||
@@ -145,16 +145,16 @@ namespace love
|
|||||||
|
|
||||||
return inserted;
|
return inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned djb2(const char * key)
|
unsigned djb2(const char * key)
|
||||||
{
|
{
|
||||||
unsigned hash = 5381;
|
unsigned hash = 5381;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while (c = *key++)
|
while ((c = *key++))
|
||||||
hash = ((hash << 5) + hash) + c;
|
hash = ((hash << 5) + hash) + c;
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
}; // StringMap
|
}; // StringMap
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
* claim that you wrote the original software. If you use this software
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
@@ -33,8 +33,8 @@ namespace openal
|
|||||||
{
|
{
|
||||||
|
|
||||||
Source::Source(Pool * pool, love::sound::SoundData * soundData)
|
Source::Source(Pool * pool, love::sound::SoundData * soundData)
|
||||||
: love::audio::Source(Source::TYPE_STATIC), pool(pool), pitch(1.0f),
|
: love::audio::Source(Source::TYPE_STATIC), pool(pool), valid(false),
|
||||||
volume(1.0f), looping(false), decoder(0), valid(false)
|
pitch(1.0f), volume(1.0f), looping(false), decoder(0)
|
||||||
{
|
{
|
||||||
alGenBuffers(1, buffers);
|
alGenBuffers(1, buffers);
|
||||||
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBits());
|
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBits());
|
||||||
@@ -48,8 +48,8 @@ namespace openal
|
|||||||
}
|
}
|
||||||
|
|
||||||
Source::Source(Pool * pool, love::sound::Decoder * decoder)
|
Source::Source(Pool * pool, love::sound::Decoder * decoder)
|
||||||
: love::audio::Source(Source::TYPE_STREAM), pool(pool), pitch(1.0f),
|
: love::audio::Source(Source::TYPE_STREAM), pool(pool), valid(false),
|
||||||
volume(1.0f), looping(false), decoder(decoder), valid(false)
|
pitch(1.0f), volume(1.0f), looping(false), decoder(decoder)
|
||||||
{
|
{
|
||||||
decoder->retain();
|
decoder->retain();
|
||||||
alGenBuffers(MAX_BUFFERS, buffers);
|
alGenBuffers(MAX_BUFFERS, buffers);
|
||||||
@@ -65,13 +65,13 @@ namespace openal
|
|||||||
{
|
{
|
||||||
stop();
|
stop();
|
||||||
alDeleteBuffers((type == TYPE_STATIC) ? 1 : MAX_BUFFERS, buffers);
|
alDeleteBuffers((type == TYPE_STATIC) ? 1 : MAX_BUFFERS, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
love::audio::Source * Source::copy()
|
love::audio::Source * Source::copy()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::play()
|
void Source::play()
|
||||||
{
|
{
|
||||||
valid = pool->play(this, source);
|
valid = pool->play(this, source);
|
||||||
@@ -84,7 +84,7 @@ namespace openal
|
|||||||
{
|
{
|
||||||
pool->stop(this);
|
pool->stop(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::pause()
|
void Source::pause()
|
||||||
{
|
{
|
||||||
pool->pause();
|
pool->pause();
|
||||||
@@ -99,13 +99,13 @@ namespace openal
|
|||||||
{
|
{
|
||||||
pool->rewind();
|
pool->rewind();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Source::isStopped() const
|
bool Source::isStopped() const
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
{
|
{
|
||||||
ALenum state;
|
ALenum state;
|
||||||
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
alGetSourcei(source, AL_SOURCE_STATE, &state);
|
||||||
return (state == AL_STOPPED);
|
return (state == AL_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ namespace openal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::setPitch(float pitch)
|
void Source::setPitch(float pitch)
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
@@ -151,7 +151,7 @@ namespace openal
|
|||||||
|
|
||||||
this->pitch = pitch;
|
this->pitch = pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Source::getPitch() const
|
float Source::getPitch() const
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
@@ -164,7 +164,7 @@ namespace openal
|
|||||||
// In case the Source isn't playing.
|
// In case the Source isn't playing.
|
||||||
return pitch;
|
return pitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::setVolume(float volume)
|
void Source::setVolume(float volume)
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
@@ -174,7 +174,7 @@ namespace openal
|
|||||||
|
|
||||||
this->volume = volume;
|
this->volume = volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Source::getVolume() const
|
float Source::getVolume() const
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
@@ -194,40 +194,40 @@ namespace openal
|
|||||||
alSourcefv(source, AL_POSITION, v);
|
alSourcefv(source, AL_POSITION, v);
|
||||||
|
|
||||||
setFloatv(position, v);
|
setFloatv(position, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::getPosition(float * v) const
|
void Source::getPosition(float * v) const
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
alGetSourcefv(source, AL_POSITION, v);
|
alGetSourcefv(source, AL_POSITION, v);
|
||||||
else
|
else
|
||||||
setFloatv(v, position);
|
setFloatv(v, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::setVelocity(float * v)
|
void Source::setVelocity(float * v)
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
alSourcefv(source, AL_VELOCITY, v);
|
alSourcefv(source, AL_VELOCITY, v);
|
||||||
|
|
||||||
setFloatv(velocity, v);
|
setFloatv(velocity, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::getVelocity(float * v) const
|
void Source::getVelocity(float * v) const
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
alGetSourcefv(source, AL_VELOCITY, v);
|
alGetSourcefv(source, AL_VELOCITY, v);
|
||||||
else
|
else
|
||||||
setFloatv(v, velocity);
|
setFloatv(v, velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::setDirection(float * v)
|
void Source::setDirection(float * v)
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
alSourcefv(source, AL_DIRECTION, v);
|
alSourcefv(source, AL_DIRECTION, v);
|
||||||
else
|
else
|
||||||
setFloatv(direction, v);
|
setFloatv(direction, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::getDirection(float * v) const
|
void Source::getDirection(float * v) const
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
@@ -236,17 +236,17 @@ namespace openal
|
|||||||
setFloatv(v, direction);
|
setFloatv(v, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::setLooping(bool looping)
|
void Source::setLooping(bool looping)
|
||||||
{
|
{
|
||||||
if(valid && type == TYPE_STATIC)
|
if(valid && type == TYPE_STATIC)
|
||||||
alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE);
|
alSourcei(source, AL_LOOPING, looping ? AL_TRUE : AL_FALSE);
|
||||||
|
|
||||||
this->looping = looping;
|
this->looping = looping;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Source::isLooping() const
|
bool Source::isLooping() const
|
||||||
{
|
{
|
||||||
return looping;
|
return looping;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::playAtomic()
|
void Source::playAtomic()
|
||||||
@@ -259,15 +259,15 @@ namespace openal
|
|||||||
{
|
{
|
||||||
int usedBuffers = 0;
|
int usedBuffers = 0;
|
||||||
|
|
||||||
for(int i = 0; i < MAX_BUFFERS; i++)
|
for(unsigned int i = 0; i < MAX_BUFFERS; i++)
|
||||||
{
|
{
|
||||||
int decoded = streamAtomic(buffers[i], decoder);
|
int decoded = streamAtomic(buffers[i], decoder);
|
||||||
++usedBuffers;
|
++usedBuffers;
|
||||||
if(decoded < decoder->getSize())
|
if(decoded < decoder->getSize())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(usedBuffers > 0)
|
if(usedBuffers > 0)
|
||||||
alSourceQueueBuffers(source, usedBuffers, buffers);
|
alSourceQueueBuffers(source, usedBuffers, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,10 +294,10 @@ namespace openal
|
|||||||
int queued = 0;
|
int queued = 0;
|
||||||
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
|
||||||
|
|
||||||
while(queued--)
|
while(queued--)
|
||||||
{
|
{
|
||||||
ALuint buffer;
|
ALuint buffer;
|
||||||
alSourceUnqueueBuffers(source, 1, &buffer);
|
alSourceUnqueueBuffers(source, 1, &buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ namespace openal
|
|||||||
rewindAtomic();
|
rewindAtomic();
|
||||||
valid = false;
|
valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Source::pauseAtomic()
|
void Source::pauseAtomic()
|
||||||
{
|
{
|
||||||
if(valid)
|
if(valid)
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
* claim that you wrote the original software. If you use this software
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "Event.h"
|
#include "Event.h"
|
||||||
@@ -33,12 +33,12 @@ namespace sdl
|
|||||||
{
|
{
|
||||||
return "love.event.sdl";
|
return "love.event.sdl";
|
||||||
}
|
}
|
||||||
|
|
||||||
Event::Event()
|
Event::Event()
|
||||||
{
|
{
|
||||||
SDL_EnableUNICODE(1);
|
SDL_EnableUNICODE(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Event::pump()
|
void Event::pump()
|
||||||
{
|
{
|
||||||
SDL_PumpEvents();
|
SDL_PumpEvents();
|
||||||
@@ -66,12 +66,12 @@ namespace sdl
|
|||||||
return ok && convert(e, message);
|
return ok && convert(e, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Event::push(Message & message)
|
bool Event::push(Message & message)
|
||||||
{
|
{
|
||||||
static SDL_Event e;
|
static SDL_Event e;
|
||||||
bool ok = convert(message, e);
|
bool ok = convert(message, e);
|
||||||
return ok && (SDL_PushEvent(&e) == 0);
|
return ok && (SDL_PushEvent(&e) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Event::convert(SDL_Event & e, Message & m)
|
bool Event::convert(SDL_Event & e, Message & m)
|
||||||
{
|
{
|
||||||
@@ -130,6 +130,8 @@ namespace sdl
|
|||||||
case Event::TYPE_QUIT:
|
case Event::TYPE_QUIT:
|
||||||
e.type = SDL_QUIT;
|
e.type = SDL_QUIT;
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -41,31 +41,33 @@ namespace sdl
|
|||||||
if(!Event::getConstant(str, msg.type))
|
if(!Event::getConstant(str, msg.type))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch(msg.type)
|
switch(msg.type)
|
||||||
{
|
{
|
||||||
case Event::TYPE_KEY_PRESSED:
|
case Event::TYPE_KEY_PRESSED:
|
||||||
if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
|
if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
|
||||||
return false;
|
return false;
|
||||||
msg.keyboard.u = (unsigned short)luaL_optint(L, 3, 0);
|
msg.keyboard.u = (unsigned short)luaL_optint(L, 3, 0);
|
||||||
return true;
|
return true;
|
||||||
case Event::TYPE_KEY_RELEASED:
|
case Event::TYPE_KEY_RELEASED:
|
||||||
if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
|
if(!Event::getConstant(luaL_checkstring(L, 2), msg.keyboard.k))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
case Event::TYPE_MOUSE_PRESSED:
|
case Event::TYPE_MOUSE_PRESSED:
|
||||||
case Event::TYPE_MOUSE_RELEASED:
|
case Event::TYPE_MOUSE_RELEASED:
|
||||||
if(!Event::getConstant(luaL_checkstring(L, 2), msg.mouse.b))
|
if(!Event::getConstant(luaL_checkstring(L, 2), msg.mouse.b))
|
||||||
return false;
|
return false;
|
||||||
msg.mouse.x = luaL_checkint(L, 3);
|
msg.mouse.x = luaL_checkint(L, 3);
|
||||||
msg.mouse.y = luaL_checkint(L, 4);
|
msg.mouse.y = luaL_checkint(L, 4);
|
||||||
return true;
|
return true;
|
||||||
case Event::TYPE_JOYSTICK_PRESSED:
|
case Event::TYPE_JOYSTICK_PRESSED:
|
||||||
case Event::TYPE_JOYSTICK_RELEASED:
|
case Event::TYPE_JOYSTICK_RELEASED:
|
||||||
msg.joystick.index = luaL_checkint(L, 2);
|
msg.joystick.index = luaL_checkint(L, 2);
|
||||||
msg.joystick.button = luaL_checkint(L, 3);
|
msg.joystick.button = luaL_checkint(L, 3);
|
||||||
return true;
|
return true;
|
||||||
case Event::TYPE_QUIT:
|
case Event::TYPE_QUIT:
|
||||||
return true;
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -80,52 +82,54 @@ namespace sdl
|
|||||||
|
|
||||||
lua_pushstring(L, str);
|
lua_pushstring(L, str);
|
||||||
|
|
||||||
switch(msg.type)
|
switch(msg.type)
|
||||||
{
|
{
|
||||||
case Event::TYPE_KEY_PRESSED:
|
case Event::TYPE_KEY_PRESSED:
|
||||||
if(!Event::getConstant(msg.keyboard.k, str))
|
if(!Event::getConstant(msg.keyboard.k, str))
|
||||||
return 0;
|
return 0;
|
||||||
lua_pushstring(L, str);
|
lua_pushstring(L, str);
|
||||||
lua_pushinteger(L, msg.keyboard.u);
|
lua_pushinteger(L, msg.keyboard.u);
|
||||||
return 3;
|
return 3;
|
||||||
case Event::TYPE_KEY_RELEASED:
|
case Event::TYPE_KEY_RELEASED:
|
||||||
if(!Event::getConstant(msg.keyboard.k, str))
|
if(!Event::getConstant(msg.keyboard.k, str))
|
||||||
return 0;
|
return 0;
|
||||||
lua_pushstring(L, str);
|
lua_pushstring(L, str);
|
||||||
return 2;
|
return 2;
|
||||||
case Event::TYPE_MOUSE_PRESSED:
|
case Event::TYPE_MOUSE_PRESSED:
|
||||||
case Event::TYPE_MOUSE_RELEASED:
|
case Event::TYPE_MOUSE_RELEASED:
|
||||||
if(!Event::getConstant(msg.mouse.b, str))
|
if(!Event::getConstant(msg.mouse.b, str))
|
||||||
return 0;
|
return 0;
|
||||||
lua_pushinteger(L, msg.mouse.x);
|
lua_pushinteger(L, msg.mouse.x);
|
||||||
lua_pushinteger(L, msg.mouse.y);
|
lua_pushinteger(L, msg.mouse.y);
|
||||||
lua_pushstring(L, str);
|
lua_pushstring(L, str);
|
||||||
return 4;
|
return 4;
|
||||||
case Event::TYPE_JOYSTICK_PRESSED:
|
case Event::TYPE_JOYSTICK_PRESSED:
|
||||||
case Event::TYPE_JOYSTICK_RELEASED:
|
case Event::TYPE_JOYSTICK_RELEASED:
|
||||||
lua_pushinteger(L, msg.joystick.index);
|
lua_pushinteger(L, msg.joystick.index);
|
||||||
lua_pushinteger(L, msg.joystick.button);
|
lua_pushinteger(L, msg.joystick.button);
|
||||||
return 3;
|
return 3;
|
||||||
case Event::TYPE_QUIT:
|
case Event::TYPE_QUIT:
|
||||||
return 1;
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int poll_i(lua_State * L)
|
static int poll_i(lua_State * L)
|
||||||
{
|
{
|
||||||
static Event::Message m;
|
static Event::Message m;
|
||||||
|
|
||||||
while(instance->poll(m))
|
while(instance->poll(m))
|
||||||
{
|
{
|
||||||
int args = push_message(L, m);
|
int args = push_message(L, m);
|
||||||
if(args > 0)
|
if(args > 0)
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No pending events.
|
// No pending events.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_pump(lua_State * L)
|
int w_pump(lua_State * L)
|
||||||
@@ -190,13 +194,13 @@ namespace sdl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedModule w;
|
WrappedModule w;
|
||||||
w.module = instance;
|
w.module = instance;
|
||||||
w.name = "event";
|
w.name = "event";
|
||||||
w.flags = MODULE_T;
|
w.flags = MODULE_T;
|
||||||
w.functions = functions;
|
w.functions = functions;
|
||||||
w.types = 0;
|
w.types = 0;
|
||||||
|
|
||||||
return luax_register_module(L, w);
|
return luax_register_module(L, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,6 +74,8 @@ namespace physfs
|
|||||||
case WRITE:
|
case WRITE:
|
||||||
file = PHYSFS_openWrite(filename.c_str());
|
file = PHYSFS_openWrite(filename.c_str());
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (file != 0);
|
return (file != 0);
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
* claim that you wrote the original software. If you use this software
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// LOVE
|
// LOVE
|
||||||
@@ -28,7 +28,7 @@ namespace love
|
|||||||
namespace font
|
namespace font
|
||||||
{
|
{
|
||||||
ImageRasterizer::ImageRasterizer(love::image::ImageData * data, unsigned short * glyphs)
|
ImageRasterizer::ImageRasterizer(love::image::ImageData * data, unsigned short * glyphs)
|
||||||
: imageData(imageData)
|
: imageData(data)
|
||||||
{
|
{
|
||||||
imageData->retain();
|
imageData->retain();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "Image.h"
|
||||||
|
|
||||||
|
namespace love
|
||||||
|
{
|
||||||
|
namespace graphics
|
||||||
|
{
|
||||||
|
Image::~Image()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::getConstant(const char * in, FilterMode & out)
|
||||||
|
{
|
||||||
|
return filterModes.find(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::getConstant(FilterMode in, const char *& out)
|
||||||
|
{
|
||||||
|
return filterModes.find(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::getConstant(const char * in, WrapMode & out)
|
||||||
|
{
|
||||||
|
return wrapModes.find(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::getConstant(WrapMode in, const char *& out)
|
||||||
|
{
|
||||||
|
return wrapModes.find(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM>::Entry Image::filterModeEntries[] =
|
||||||
|
{
|
||||||
|
{ "linear", Image::FILTER_LINEAR },
|
||||||
|
{ "nearest", Image::FILTER_NEAREST },
|
||||||
|
};
|
||||||
|
|
||||||
|
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM> Image::filterModes(Image::filterModeEntries, sizeof(Image::filterModeEntries));
|
||||||
|
|
||||||
|
StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM>::Entry Image::wrapModeEntries[] =
|
||||||
|
{
|
||||||
|
{ "clamp", Image::WRAP_CLAMP },
|
||||||
|
{ "repeat", Image::WRAP_REPEAT },
|
||||||
|
};
|
||||||
|
|
||||||
|
StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM> Image::wrapModes(Image::wrapModeEntries, sizeof(Image::wrapModeEntries));
|
||||||
|
|
||||||
|
|
||||||
|
} // graphics
|
||||||
|
} // love
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
* claim that you wrote the original software. If you use this software
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#ifndef LOVE_GRAPHICS_IMAGE_H
|
#ifndef LOVE_GRAPHICS_IMAGE_H
|
||||||
@@ -24,6 +24,7 @@
|
|||||||
// LOVE
|
// LOVE
|
||||||
#include <graphics/Volatile.h>
|
#include <graphics/Volatile.h>
|
||||||
#include <graphics/Drawable.h>
|
#include <graphics/Drawable.h>
|
||||||
|
#include <common/StringMap.h>
|
||||||
|
|
||||||
namespace love
|
namespace love
|
||||||
{
|
{
|
||||||
@@ -36,14 +37,16 @@ namespace graphics
|
|||||||
|
|
||||||
enum WrapMode
|
enum WrapMode
|
||||||
{
|
{
|
||||||
WRAP_CLAMP,
|
WRAP_CLAMP = 1,
|
||||||
WRAP_REPEAT
|
WRAP_REPEAT,
|
||||||
|
WRAP_MAX_ENUM
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FilterMode
|
enum FilterMode
|
||||||
{
|
{
|
||||||
FILTER_LINEAR,
|
FILTER_LINEAR = 1,
|
||||||
FILTER_NEAREST
|
FILTER_NEAREST,
|
||||||
|
FILTER_MAX_ENUM
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Filter
|
struct Filter
|
||||||
@@ -58,7 +61,19 @@ namespace graphics
|
|||||||
WrapMode t;
|
WrapMode t;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~Image(){};
|
virtual ~Image();
|
||||||
|
|
||||||
|
static bool getConstant(const char * in, FilterMode & out);
|
||||||
|
static bool getConstant(FilterMode in, const char *& out);
|
||||||
|
static bool getConstant(const char * in, WrapMode & out);
|
||||||
|
static bool getConstant(WrapMode in, const char *& out);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
static StringMap<FilterMode, FILTER_MAX_ENUM>::Entry filterModeEntries[];
|
||||||
|
static StringMap<FilterMode, FILTER_MAX_ENUM> filterModes;
|
||||||
|
static StringMap<WrapMode, WRAP_MAX_ENUM>::Entry wrapModeEntries[];
|
||||||
|
static StringMap<WrapMode, WRAP_MAX_ENUM> wrapModes;
|
||||||
|
|
||||||
}; // Image
|
}; // Image
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace opengl
|
|||||||
{
|
{
|
||||||
|
|
||||||
Glyph::Glyph(love::font::GlyphData * data)
|
Glyph::Glyph(love::font::GlyphData * data)
|
||||||
: data(data), texture(0), width((float)data->getWidth()), height((float)data->getHeight())
|
: data(data), width((float)data->getWidth()), height((float)data->getHeight()), texture(0)
|
||||||
{
|
{
|
||||||
data->retain();
|
data->retain();
|
||||||
data->getWidth();
|
data->getWidth();
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ namespace opengl
|
|||||||
void Image::setFilter(Image::Filter f)
|
void Image::setFilter(Image::Filter f)
|
||||||
{
|
{
|
||||||
GLint gmin, gmag;
|
GLint gmin, gmag;
|
||||||
|
gmin = gmag = 0; // so that they're not used uninitialized
|
||||||
|
|
||||||
switch(f.min)
|
switch(f.min)
|
||||||
{
|
{
|
||||||
@@ -132,6 +133,8 @@ namespace opengl
|
|||||||
case FILTER_NEAREST:
|
case FILTER_NEAREST:
|
||||||
gmin = GL_NEAREST;
|
gmin = GL_NEAREST;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(f.mag)
|
switch(f.mag)
|
||||||
@@ -142,12 +145,14 @@ namespace opengl
|
|||||||
case FILTER_NEAREST:
|
case FILTER_NEAREST:
|
||||||
gmag = GL_NEAREST;
|
gmag = GL_NEAREST;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bind();
|
bind();
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gmin);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gmin);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gmag);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gmag);
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Filter Image::getFilter() const
|
Image::Filter Image::getFilter() const
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2006-2010 LOVE Development Team
|
* Copyright (c) 2006-2010 LOVE Development Team
|
||||||
*
|
*
|
||||||
* This software is provided 'as-is', without any express or implied
|
* This software is provided 'as-is', without any express or implied
|
||||||
* warranty. In no event will the authors be held liable for any damages
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
* arising from the use of this software.
|
* arising from the use of this software.
|
||||||
*
|
*
|
||||||
* Permission is granted to anyone to use this software for any purpose,
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
* including commercial applications, and to alter it and redistribute it
|
* including commercial applications, and to alter it and redistribute it
|
||||||
* freely, subject to the following restrictions:
|
* freely, subject to the following restrictions:
|
||||||
*
|
*
|
||||||
* 1. The origin of this software must not be misrepresented; you must not
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
* claim that you wrote the original software. If you use this software
|
* claim that you wrote the original software. If you use this software
|
||||||
* in a product, an acknowledgment in the product documentation would be
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
* appreciated but is not required.
|
* appreciated but is not required.
|
||||||
* 2. Altered source versions must be plainly marked as such, and must not be
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
* misrepresented as being the original software.
|
* misrepresented as being the original software.
|
||||||
* 3. This notice may not be removed or altered from any source distribution.
|
* 3. This notice may not be removed or altered from any source distribution.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include "ImageFont.h"
|
#include "ImageFont.h"
|
||||||
@@ -31,7 +31,7 @@ namespace graphics
|
|||||||
namespace opengl
|
namespace opengl
|
||||||
{
|
{
|
||||||
ImageFont::ImageFont(Image * image, std::string glyphs)
|
ImageFont::ImageFont(Image * image, std::string glyphs)
|
||||||
: Font(0), glyphs(glyphs), image(image)
|
: Font(0), image(image), glyphs(glyphs)
|
||||||
|
|
||||||
{
|
{
|
||||||
image->retain();
|
image->retain();
|
||||||
|
|||||||
@@ -48,10 +48,19 @@ namespace opengl
|
|||||||
|
|
||||||
int w_Image_setFilter(lua_State * L)
|
int w_Image_setFilter(lua_State * L)
|
||||||
{
|
{
|
||||||
Image * t = luax_checkimage(L, 1);
|
Image * t = luax_checkimage(L, 1);
|
||||||
Image::Filter f;
|
Image::Filter f;
|
||||||
f.min = (Image::FilterMode)luaL_checkint(L, 2);
|
Image::FilterMode min;
|
||||||
f.mag = (Image::FilterMode)luaL_checkint(L, 3);
|
Image::FilterMode mag;
|
||||||
|
const char * minstr = luaL_checkstring(L, 2);
|
||||||
|
const char * magstr = luaL_checkstring(L, 3);
|
||||||
|
if (!Image::getConstant(minstr, min))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", minstr);
|
||||||
|
if (!Image::getConstant(magstr, mag))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", magstr);
|
||||||
|
|
||||||
|
f.min = min;
|
||||||
|
f.mag = mag;
|
||||||
t->setFilter(f);
|
t->setFilter(f);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -60,27 +69,52 @@ namespace opengl
|
|||||||
{
|
{
|
||||||
Image * t = luax_checkimage(L, 1);
|
Image * t = luax_checkimage(L, 1);
|
||||||
Image::Filter f = t->getFilter();
|
Image::Filter f = t->getFilter();
|
||||||
lua_pushinteger(L, f.min);
|
Image::FilterMode min = f.min;
|
||||||
lua_pushinteger(L, f.mag);
|
Image::FilterMode mag = f.mag;
|
||||||
|
const char * minstr;
|
||||||
|
const char * magstr;
|
||||||
|
if (!Image::getConstant(min, minstr))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", minstr);
|
||||||
|
if (!Image::getConstant(mag, magstr))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", magstr);
|
||||||
|
lua_pushstring(L, minstr);
|
||||||
|
lua_pushstring(L, magstr);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Image_setWrap(lua_State * L)
|
int w_Image_setWrap(lua_State * L)
|
||||||
{
|
{
|
||||||
Image * t = luax_checkimage(L, 1);
|
Image * i = luax_checkimage(L, 1);
|
||||||
Image::Wrap w;
|
Image::Wrap w;
|
||||||
w.s = (Image::WrapMode)luaL_checkint(L, 2);
|
Image::WrapMode s;
|
||||||
w.t = (Image::WrapMode)luaL_checkint(L, 3);
|
Image::WrapMode t;
|
||||||
t->setWrap(w);
|
const char * sstr = luaL_checkstring(L, 2);
|
||||||
|
const char * tstr = luaL_checkstring(L, 3);
|
||||||
|
if (!Image::getConstant(sstr, s))
|
||||||
|
return luaL_error(L, "Invalid wrap mode: %s", sstr);
|
||||||
|
if (!Image::getConstant(tstr, t))
|
||||||
|
return luaL_error(L, "Invalid wrap mode, %s", tstr);
|
||||||
|
|
||||||
|
w.s = s;
|
||||||
|
w.t = t;
|
||||||
|
i->setWrap(w);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Image_getWrap(lua_State * L)
|
int w_Image_getWrap(lua_State * L)
|
||||||
{
|
{
|
||||||
Image * t = luax_checkimage(L, 1);
|
Image * i = luax_checkimage(L, 1);
|
||||||
Image::Wrap w = t->getWrap();
|
Image::Wrap w = i->getWrap();
|
||||||
lua_pushinteger(L, w.s);
|
Image::WrapMode s = w.s;
|
||||||
lua_pushinteger(L, w.t);
|
Image::WrapMode t = w.t;
|
||||||
|
const char * sstr;
|
||||||
|
const char * tstr;
|
||||||
|
if (!Image::getConstant(s, sstr))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", sstr);
|
||||||
|
if (!Image::getConstant(t, tstr))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", tstr);
|
||||||
|
lua_pushstring(L, sstr);
|
||||||
|
lua_pushstring(L, tstr);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace love
|
|||||||
namespace image
|
namespace image
|
||||||
{
|
{
|
||||||
EncodedImageData::EncodedImageData(void * d, Format f, int s)
|
EncodedImageData::EncodedImageData(void * d, Format f, int s)
|
||||||
: data(d), format(f), size(s)
|
: data(d), size(s), format(f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,16 +154,16 @@ namespace devil
|
|||||||
|
|
||||||
void ImageData::setPixel(int x, int y, pixel c)
|
void ImageData::setPixel(int x, int y, pixel c)
|
||||||
{
|
{
|
||||||
int tx = x > width-1 ? width-1 : x;
|
//int tx = x > width-1 ? width-1 : x;
|
||||||
int ty = y > height-1 ? height-1 : y;
|
//int ty = y > height-1 ? height-1 : y; // not using these seems to not break anything
|
||||||
pixel * pixels = (pixel *)getData();
|
pixel * pixels = (pixel *)getData();
|
||||||
pixels[y*width+x] = c;
|
pixels[y*width+x] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixel ImageData::getPixel(int x, int y) const
|
pixel ImageData::getPixel(int x, int y) const
|
||||||
{
|
{
|
||||||
int tx = x > width-1 ? width-1 : x;
|
//int tx = x > width-1 ? width-1 : x;
|
||||||
int ty = y > height-1 ? height-1 : y;
|
//int ty = y > height-1 ? height-1 : y; // not using these seems to not break anything
|
||||||
pixel * pixels = (pixel *)getData();
|
pixel * pixels = (pixel *)getData();
|
||||||
return pixels[y*width+x];
|
return pixels[y*width+x];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace box2d
|
|||||||
|
|
||||||
void PrismaticJoint::setMotorEnabled(bool motor)
|
void PrismaticJoint::setMotorEnabled(bool motor)
|
||||||
{
|
{
|
||||||
return joint->EnableMotor(true);
|
return joint->EnableMotor(motor);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PrismaticJoint::isMotorEnabled() const
|
bool PrismaticJoint::isMotorEnabled() const
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ namespace box2d
|
|||||||
for(int i = 1;i<=argc;i++)
|
for(int i = 1;i<=argc;i++)
|
||||||
{
|
{
|
||||||
size_t bpos = (size_t)(lua_tointeger(L, i)-1);
|
size_t bpos = (size_t)(lua_tointeger(L, i)-1);
|
||||||
if(bpos < 0 || bpos > 16)
|
if(bpos > 16)
|
||||||
return luaL_error(L, "Values must be in range 1-16.");
|
return luaL_error(L, "Values must be in range 1-16.");
|
||||||
b.set(bpos, true);
|
b.set(bpos, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user