Merged default into minor

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2014-09-18 02:15:20 -03:00
12 changed files with 141 additions and 30 deletions
+25 -4
View File
@@ -46,6 +46,7 @@ else()
endif()
option(LOVE_JIT "Use LuaJIT" TRUE)
option(LOVE_MPG123 "Use mpg123" TRUE)
if(LOVE_JIT)
message(STATUS "LuaJIT: Enabled")
@@ -53,6 +54,10 @@ else()
message(STATUS "LuaJIT: Disabled")
endif()
if(NOT LOVE_MPG123)
add_definitions(-DLOVE_NOMPG123)
endif()
message(STATUS "Target platform: ${LOVE_TARGET_PLATFORM}")
find_package(OpenGL)
@@ -612,8 +617,6 @@ set(LOVE_SRC_MODULE_SOUND_LULLABY
src/modules/sound/lullaby/GmeDecoder.h
src/modules/sound/lullaby/ModPlugDecoder.cpp
src/modules/sound/lullaby/ModPlugDecoder.h
src/modules/sound/lullaby/Mpg123Decoder.cpp
src/modules/sound/lullaby/Mpg123Decoder.h
src/modules/sound/lullaby/Sound.cpp
src/modules/sound/lullaby/Sound.h
src/modules/sound/lullaby/VorbisDecoder.cpp
@@ -622,6 +625,14 @@ set(LOVE_SRC_MODULE_SOUND_LULLABY
src/modules/sound/lullaby/WaveDecoder.h
)
if(LOVE_MPG123)
set(LOVE_SRC_MODULE_SOUND_LULLABY
${LOVE_SRC_MODULE_SOUND_LULLABY}
src/modules/sound/lullaby/Mpg123Decoder.cpp
src/modules/sound/lullaby/Mpg123Decoder.h
)
endif()
set(LOVE_SRC_MODULE_SOUND
${LOVE_SRC_MODULE_SOUND_ROOT}
${LOVE_SRC_MODULE_SOUND_LULLABY}
@@ -1130,7 +1141,6 @@ set(LOVE_MEGA_3P
${MEGA_LIBVORBIS}
${MEGA_LUA}
${MEGA_MODPLUG}
${MEGA_MPEG123}
${MEGA_OPENAL}
${MEGA_PHYSFS}
${MEGA_SDL2MAIN}
@@ -1138,6 +1148,14 @@ set(LOVE_MEGA_3P
${MEGA_ZLIB}
)
if(LOVE_MPG123)
set(LOVE_MEGA_3P
${LOVE_MEGA_3P}
${MEGA_MPEG123}
)
endif()
set(LOVE_LINK_LIBRARIES
${OPENGL_gl_LIBRARY}
${LOVE_MEGA_3P}
@@ -1177,7 +1195,10 @@ target_link_libraries(love liblove)
# Add post build steps to move the DLLs next to the binary. Otherwise
# running/debugging the binary will not work from inside VS.
add_move_dll(love ${MEGA_MPEG123})
if(LOVE_MPG123)
add_move_dll(love ${MEGA_MPEG123})
endif()
add_move_dll(love ${MEGA_SDL2})
add_move_dll(love ${MEGA_OPENAL})
+4 -1
View File
@@ -72,7 +72,10 @@ Source::Source(Pool *pool, love::sound::SoundData *soundData)
, toLoop(0)
{
ALenum fmt = getFormat(soundData->getChannels(), soundData->getBitDepth());
staticBuffer = new StaticDataBuffer(fmt, soundData->getData(), soundData->getSize(), soundData->getSampleRate());
staticBuffer.set(new StaticDataBuffer(fmt, soundData->getData(), soundData->getSize(), soundData->getSampleRate()));
// The buffer has a +2 retain count right now, but we want it to have +1.
staticBuffer->release();
float z[3] = {0, 0, 0};
+6 -5
View File
@@ -689,6 +689,12 @@ Color Graphics::getBackgroundColor() const
void Graphics::setFont(Font *font)
{
// Hack: the Lua-facing love.graphics.print function will set the current
// font if needed, but only on its first call... we want to make sure a nil
// font is never accidentally set (e.g. via love.graphics.reset.)
if (font == nullptr)
return;
DisplayState &state = states.back();
state.font.set(font);
}
@@ -1319,11 +1325,6 @@ void Graphics::pop()
{
DisplayState &newstate = states[states.size() - 2];
// Hack: the Lua-facing love.graphics.print function will set the current
// font if needed, but only on its first call... we always want a font.
if (newstate.font.get() == nullptr)
newstate.font.set(states.back().font.get());
restoreStateChecked(newstate);
// The last two states in the stack should be equal now.
+5
View File
@@ -144,6 +144,11 @@ public:
virtual double getPixelScale() const = 0;
virtual double toPixels(double x) const = 0;
virtual void toPixels(double wx, double wy, double &px, double &py) const = 0;
virtual double fromPixels(double x) const = 0;
virtual void fromPixels(double px, double py, double &wx, double &wy) const = 0;
virtual const void *getHandle() const = 0;
virtual bool showMessageBox(MessageBoxType type, const std::string &title, const std::string &message, bool attachtowindow) = 0;
+24
View File
@@ -672,6 +672,30 @@ double Window::getPixelScale() const
return scale;
}
double Window::toPixels(double x) const
{
return x * getPixelScale();
}
void Window::toPixels(double wx, double wy, double &px, double &py) const
{
double scale = getPixelScale();
px = wx * scale;
py = wy * scale;
}
double Window::fromPixels(double x) const
{
return x / getPixelScale();
}
void Window::fromPixels(double px, double py, double &wx, double &wy) const
{
double scale = getPixelScale();
wx = px / scale;
wy = py / scale;
}
const void *Window::getHandle() const
{
return window;
+5
View File
@@ -82,6 +82,11 @@ public:
double getPixelScale() const;
double toPixels(double x) const;
void toPixels(double wx, double wy, double &px, double &py) const;
double fromPixels(double x) const;
void fromPixels(double px, double py, double &wx, double &wy) const;
const void *getHandle() const;
bool showMessageBox(MessageBoxType type, const std::string &title, const std::string &message, bool attachtowindow);
+44
View File
@@ -307,6 +307,48 @@ int w_getPixelScale(lua_State *L)
return 1;
}
int w_toPixels(lua_State *L)
{
double wx = luaL_checknumber(L, 1);
if (lua_isnoneornil(L, 2))
{
lua_pushnumber(L, instance()->toPixels(wx));
return 1;
}
double wy = luaL_checknumber(L, 2);
double px = 0.0, py = 0.0;
instance()->toPixels(wx, wy, px, py);
lua_pushnumber(L, px);
lua_pushnumber(L, py);
return 2;
}
int w_fromPixels(lua_State *L)
{
double px = luaL_checknumber(L, 1);
if (lua_isnoneornil(L, 2))
{
lua_pushnumber(L, instance()->fromPixels(px));
return 1;
}
double py = luaL_checknumber(L, 2);
double wx = 0.0, wy = 0.0;
instance()->fromPixels(px, py, wx, wy);
lua_pushnumber(L, wx);
lua_pushnumber(L, wy);
return 2;
}
int w_minimize(lua_State* /*L*/)
{
instance()->minimize();
@@ -392,6 +434,8 @@ static const luaL_Reg functions[] =
{ "hasMouseFocus", w_hasMouseFocus },
{ "isVisible", w_isVisible },
{ "getPixelScale", w_getPixelScale },
{ "toPixels", w_toPixels },
{ "fromPixels", w_fromPixels },
{ "minimize", w_minimize },
{ "showMessageBox", w_showMessageBox },
{ 0, 0 }
+2
View File
@@ -46,6 +46,8 @@ int w_hasFocus(lua_State *L);
int w_hasMouseFocus(lua_State *L);
int w_isVisible(lua_State *L);
int w_getPixelScale(lua_State *L);
int w_toPixels(lua_State *L);
int w_fromPixels(lua_State *L);
int w_minimize(lua_State *L);
int w_showMessageBox(lua_State *L);
extern "C" LOVE_EXPORT int luaopen_love_window(lua_State *L);
+6 -5
View File
@@ -81,6 +81,8 @@ end
-- Returns the leaf of a full path.
function love.path.leaf(p)
p = love.path.normalslashes(p)
local a = 1
local last = p
@@ -1420,9 +1422,8 @@ function love.nogame()
g_time = g_time + dt / 2
local int, frac = math.modf(g_time)
update_rain(frac)
local scale = love.window.getPixelScale()
inspector.x = love.graphics.getWidth() * 0.45 / scale
inspector.y = love.graphics.getHeight() * 0.55 / scale
inspector.x = love.window.fromPixels(love.graphics.getWidth() * 0.45)
inspector.y = love.window.fromPixels(love.graphics.getHeight() * 0.55)
end
local function draw_grid()
@@ -1552,7 +1553,7 @@ function love.errhand(msg)
end
if love.audio then love.audio.stop() end
love.graphics.reset()
local font = love.graphics.setNewFont(math.floor(14 * love.window.getPixelScale()))
local font = love.graphics.setNewFont(math.floor(love.window.toPixels(14)))
local sRGB = select(3, love.window.getMode()).srgb
if sRGB and love.math then
@@ -1586,7 +1587,7 @@ function love.errhand(msg)
p = string.gsub(p, "%[string \"(.-)\"%]", "%1")
local function draw()
local pos = 70 * love.window.getPixelScale()
local pos = love.window.toPixels(70)
love.graphics.clear()
love.graphics.printf(p, pos, pos, love.graphics.getWidth() - pos)
love.graphics.present()
+14 -15
View File
@@ -168,6 +168,8 @@ const unsigned char boot_lua[] =
0x66, 0x20, 0x6f, 0x66, 0x20, 0x61, 0x20, 0x66, 0x75, 0x6c, 0x6c, 0x20, 0x70, 0x61, 0x74, 0x68, 0x2e, 0x0a,
0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x61, 0x74, 0x68,
0x2e, 0x6c, 0x65, 0x61, 0x66, 0x28, 0x70, 0x29, 0x0a,
0x09, 0x70, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x70, 0x61, 0x74, 0x68, 0x2e, 0x6e, 0x6f, 0x72,
0x6d, 0x61, 0x6c, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x65, 0x73, 0x28, 0x70, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x61, 0x20, 0x3d, 0x20, 0x31, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x6c, 0x61, 0x73, 0x74, 0x20, 0x3d, 0x20, 0x70, 0x0a,
0x09, 0x77, 0x68, 0x69, 0x6c, 0x65, 0x20, 0x61, 0x20, 0x64, 0x6f, 0x0a,
@@ -5009,17 +5011,14 @@ const unsigned char boot_lua[] =
0x29, 0x0a,
0x09, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x72, 0x61, 0x69, 0x6e, 0x28, 0x66, 0x72, 0x61, 0x63,
0x29, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x63, 0x61, 0x6c, 0x65, 0x20, 0x3d, 0x20, 0x6c, 0x6f,
0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x67, 0x65, 0x74, 0x50, 0x69, 0x78, 0x65, 0x6c,
0x53, 0x63, 0x61, 0x6c, 0x65, 0x28, 0x29, 0x0a,
0x09, 0x09, 0x69, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x78, 0x20, 0x3d, 0x20, 0x6c, 0x6f,
0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x57, 0x69, 0x64,
0x74, 0x68, 0x28, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x34, 0x35, 0x20, 0x2f, 0x20, 0x73, 0x63, 0x61, 0x6c,
0x65, 0x0a,
0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x66, 0x72, 0x6f, 0x6d, 0x50, 0x69, 0x78, 0x65,
0x6c, 0x73, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x67,
0x65, 0x74, 0x57, 0x69, 0x64, 0x74, 0x68, 0x28, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x34, 0x35, 0x29, 0x0a,
0x09, 0x09, 0x69, 0x6e, 0x73, 0x70, 0x65, 0x63, 0x74, 0x6f, 0x72, 0x2e, 0x79, 0x20, 0x3d, 0x20, 0x6c, 0x6f,
0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x67, 0x65, 0x74, 0x48, 0x65, 0x69,
0x67, 0x68, 0x74, 0x28, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x35, 0x20, 0x2f, 0x20, 0x73, 0x63, 0x61,
0x6c, 0x65, 0x0a,
0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x66, 0x72, 0x6f, 0x6d, 0x50, 0x69, 0x78, 0x65,
0x6c, 0x73, 0x28, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x67,
0x65, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x28, 0x29, 0x20, 0x2a, 0x20, 0x30, 0x2e, 0x35, 0x35, 0x29, 0x0a,
0x09, 0x65, 0x6e, 0x64, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x64, 0x72,
0x61, 0x77, 0x5f, 0x67, 0x72, 0x69, 0x64, 0x28, 0x29, 0x0a,
@@ -5262,9 +5261,9 @@ const unsigned char boot_lua[] =
0x65, 0x74, 0x28, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 0x65,
0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x73, 0x65, 0x74, 0x4e, 0x65, 0x77, 0x46, 0x6f,
0x6e, 0x74, 0x28, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28, 0x31, 0x34, 0x20, 0x2a,
0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x67, 0x65, 0x74, 0x50, 0x69,
0x78, 0x65, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x28, 0x29, 0x29, 0x29, 0x0a,
0x6e, 0x74, 0x28, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x66, 0x6c, 0x6f, 0x6f, 0x72, 0x28, 0x6c, 0x6f, 0x76, 0x65,
0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x74, 0x6f, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x73, 0x28, 0x31,
0x34, 0x29, 0x29, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x73, 0x52, 0x47, 0x42, 0x20, 0x3d, 0x20, 0x73, 0x65, 0x6c, 0x65,
0x63, 0x74, 0x28, 0x33, 0x2c, 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e,
0x67, 0x65, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x28, 0x29, 0x29, 0x2e, 0x73, 0x72, 0x67, 0x62, 0x0a,
@@ -5317,9 +5316,9 @@ const unsigned char boot_lua[] =
0x5c, 0x22, 0x25, 0x5d, 0x22, 0x2c, 0x20, 0x22, 0x25, 0x31, 0x22, 0x29, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x64, 0x72,
0x61, 0x77, 0x28, 0x29, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x70, 0x6f, 0x73, 0x20, 0x3d, 0x20, 0x37, 0x30, 0x20, 0x2a,
0x20, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x67, 0x65, 0x74, 0x50, 0x69,
0x78, 0x65, 0x6c, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x28, 0x29, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x70, 0x6f, 0x73, 0x20, 0x3d, 0x20, 0x6c, 0x6f, 0x76, 0x65,
0x2e, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x2e, 0x74, 0x6f, 0x50, 0x69, 0x78, 0x65, 0x6c, 0x73, 0x28, 0x37,
0x30, 0x29, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x63, 0x6c,
0x65, 0x61, 0x72, 0x28, 0x29, 0x0a,
0x09, 0x09, 0x6c, 0x6f, 0x76, 0x65, 0x2e, 0x67, 0x72, 0x61, 0x70, 0x68, 0x69, 0x63, 0x73, 0x2e, 0x70, 0x72,
+3
View File
@@ -1292,6 +1292,9 @@ do
local GLSL_VERSION = "#version 120"
local GLSL_SYNTAX = [[
#define lowp
#define mediump
#define highp
#define number float
#define Image sampler2D
#define extern uniform
+3
View File
@@ -6269,6 +6269,9 @@ const unsigned char graphics_lua[] =
0x09, 0x0a,
0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x20, 0x47, 0x4c, 0x53, 0x4c, 0x5f, 0x53, 0x59, 0x4e, 0x54, 0x41, 0x58,
0x20, 0x3d, 0x20, 0x5b, 0x5b, 0x0a,
0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x0a,
0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x6d, 0x65, 0x64, 0x69, 0x75, 0x6d, 0x70, 0x0a,
0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x0a,
0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x0a,
0x23, 0x64, 0x65, 0x66, 0x69, 0x6e, 0x65, 0x20, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x20, 0x73, 0x61, 0x6d, 0x70,