mirror of
https://github.com/love2d/love.git
synced 2026-08-15 07:41:11 +02:00
Merge in default
--HG-- branch : minor
This commit is contained in:
Regular → Executable
+14
-4
@@ -37,6 +37,10 @@ endif()
|
||||
set(LOVE_EXE_NAME love)
|
||||
set(LOVE_LIB_NAME liblove)
|
||||
|
||||
if(MSVC)
|
||||
set(LOVE_CONSOLE_EXE_NAME lovec)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(LOVE_X64 TRUE)
|
||||
set(LOVE_TARGET_PLATFORM x64)
|
||||
@@ -1294,7 +1298,7 @@ if(MSVC)
|
||||
endif()
|
||||
|
||||
add_library(${LOVE_LIB_NAME} SHARED ${LOVE_LIB_SRC} ${LOVE_RC})
|
||||
target_link_libraries(liblove ${LOVE_LINK_LIBRARIES} ${LOVE_3P})
|
||||
target_link_libraries(${LOVE_LIB_NAME} ${LOVE_LINK_LIBRARIES} ${LOVE_3P})
|
||||
|
||||
if(MEGA_EXTRA_DEPENDECIES)
|
||||
add_dependencies(${LOVE_LIB_NAME} ${MEGA_EXTRA_DEPENDECIES})
|
||||
@@ -1309,7 +1313,13 @@ endif()
|
||||
# love (executable)
|
||||
#
|
||||
add_executable(${LOVE_EXE_NAME} WIN32 src/love.cpp ${LOVE_RC})
|
||||
target_link_libraries(love liblove)
|
||||
target_link_libraries(${LOVE_EXE_NAME} ${LOVE_LIB_NAME})
|
||||
|
||||
if(MSVC)
|
||||
add_executable(${LOVE_CONSOLE_EXE_NAME} src/love.cpp ${LOVE_RC})
|
||||
target_link_libraries(${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME})
|
||||
endif()
|
||||
|
||||
|
||||
# Add post build steps to move the DLLs next to the binary. Otherwise
|
||||
# running/debugging the binary will not work from inside VS.
|
||||
@@ -1351,7 +1361,7 @@ message(STATUS "Version: ${LOVE_VERSION_STR}")
|
||||
###################################
|
||||
# CPack
|
||||
###################################
|
||||
install(TARGETS love ${LOVE_LIB_NAME} RUNTIME DESTINATION .)
|
||||
install(TARGETS ${LOVE_EXE_NAME} ${LOVE_CONSOLE_EXE_NAME} ${LOVE_LIB_NAME} RUNTIME DESTINATION .)
|
||||
|
||||
# Extra DLLs.
|
||||
if(MEGA_EXTRA_DLLS)
|
||||
@@ -1404,7 +1414,7 @@ set(CPACK_PACKAGE_VERSION_MAJOR "${LOVE_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${LOVE_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${LOVE_VERSION_REV}")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "LOVE")
|
||||
set(CPACK_PACKAGE_EXECUTABLES "love;LOVE")
|
||||
set(CPACK_PACKAGE_EXECUTABLES "${LOVE_EXE_NAME};LOVE")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt")
|
||||
|
||||
|
||||
@@ -19,12 +19,13 @@
|
||||
**/
|
||||
|
||||
#include "Memoizer.h"
|
||||
#include <cstddef>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
std::map<void *, void *> Memoizer::objectMap;
|
||||
static std::unordered_map<void *, void *> objectMap;
|
||||
|
||||
void Memoizer::add(void *key, void *val)
|
||||
{
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
#ifndef LOVE_MEMOIZER_H
|
||||
#define LOVE_MEMOIZER_H
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
@@ -31,14 +29,9 @@ class Memoizer
|
||||
public:
|
||||
|
||||
static void add(void *key, void *val);
|
||||
|
||||
static void remove(void *key);
|
||||
|
||||
static void *find(void *key);
|
||||
|
||||
private:
|
||||
|
||||
static std::map<void *, void *> objectMap;
|
||||
}; // Memoizer
|
||||
|
||||
} // love
|
||||
|
||||
+1
-1
@@ -148,7 +148,7 @@
|
||||
#endif
|
||||
|
||||
// Check we have a sane configuration
|
||||
#if !defined(LOVE_WINDOWS) && !defined(LOVE_LINUX) && !defined(LOVE_IOS) && !defined(LOVE_MACOSX)
|
||||
#if !defined(LOVE_WINDOWS) && !defined(LOVE_LINUX) && !defined(LOVE_IOS) && !defined(LOVE_MACOSX) && !defined(LOVE_ANDROID)
|
||||
# error Could not detect target platform
|
||||
#endif
|
||||
#if !defined(LOVE_LITTLE_ENDIAN) && !defined(LOVE_BIG_ENDIAN)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
namespace love
|
||||
{
|
||||
|
||||
void delay(unsigned int ms)
|
||||
void sleep(unsigned int ms)
|
||||
{
|
||||
SDL_Delay(ms);
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
namespace love
|
||||
{
|
||||
|
||||
void delay(unsigned int ms);
|
||||
void sleep(unsigned int ms);
|
||||
|
||||
} // namespace love
|
||||
|
||||
|
||||
+3
-3
@@ -76,7 +76,7 @@ struct Triangle
|
||||
Vertex a, b, c;
|
||||
};
|
||||
|
||||
inline int next_p2(int x)
|
||||
inline int nextP2(int x)
|
||||
{
|
||||
x += (x == 0);
|
||||
x--;
|
||||
@@ -84,9 +84,9 @@ inline int next_p2(int x)
|
||||
return ++x;
|
||||
}
|
||||
|
||||
inline float next_p2(float x)
|
||||
inline float nextP2(float x)
|
||||
{
|
||||
return static_cast<float>(next_p2(static_cast<int>(x)));
|
||||
return (float) nextP2((int) x);
|
||||
}
|
||||
|
||||
} // love
|
||||
|
||||
@@ -57,7 +57,7 @@ void Audio::PoolThread::threadFunction()
|
||||
}
|
||||
|
||||
pool->update();
|
||||
delay(5);
|
||||
sleep(5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,14 +142,14 @@ bool Graphics::getConstant(CompareMode in, const char *&out)
|
||||
return compareModes.find(in, out);
|
||||
}
|
||||
|
||||
bool Graphics::getConstant(const char *in, Support &out)
|
||||
bool Graphics::getConstant(const char *in, Feature &out)
|
||||
{
|
||||
return support.find(in, out);
|
||||
return features.find(in, out);
|
||||
}
|
||||
|
||||
bool Graphics::getConstant(Support in, const char *&out)
|
||||
bool Graphics::getConstant(Feature in, const char *&out)
|
||||
{
|
||||
return support.find(in, out);
|
||||
return features.find(in, out);
|
||||
}
|
||||
|
||||
bool Graphics::getConstant(const char *in, SystemLimit &out)
|
||||
@@ -263,14 +263,14 @@ StringMap<Graphics::CompareMode, Graphics::COMPARE_MAX_ENUM>::Entry Graphics::co
|
||||
|
||||
StringMap<Graphics::CompareMode, Graphics::COMPARE_MAX_ENUM> Graphics::compareModes(Graphics::compareModeEntries, sizeof(Graphics::compareModeEntries));
|
||||
|
||||
StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM>::Entry Graphics::supportEntries[] =
|
||||
StringMap<Graphics::Feature, Graphics::FEATURE_MAX_ENUM>::Entry Graphics::featureEntries[] =
|
||||
{
|
||||
{ "multicanvasformats", SUPPORT_MULTI_CANVAS_FORMATS },
|
||||
{ "clampzero", SUPPORT_CLAMP_ZERO },
|
||||
{ "lighten", SUPPORT_LIGHTEN },
|
||||
{ "multicanvasformats", FEATURE_MULTI_CANVAS_FORMATS },
|
||||
{ "clampzero", FEATURE_CLAMP_ZERO },
|
||||
{ "lighten", FEATURE_LIGHTEN },
|
||||
};
|
||||
|
||||
StringMap<Graphics::Support, Graphics::SUPPORT_MAX_ENUM> Graphics::support(Graphics::supportEntries, sizeof(Graphics::supportEntries));
|
||||
StringMap<Graphics::Feature, Graphics::FEATURE_MAX_ENUM> Graphics::features(Graphics::featureEntries, sizeof(Graphics::featureEntries));
|
||||
|
||||
StringMap<Graphics::SystemLimit, Graphics::LIMIT_MAX_ENUM>::Entry Graphics::systemLimitEntries[] =
|
||||
{
|
||||
|
||||
@@ -136,12 +136,12 @@ public:
|
||||
COMPARE_MAX_ENUM
|
||||
};
|
||||
|
||||
enum Support
|
||||
enum Feature
|
||||
{
|
||||
SUPPORT_MULTI_CANVAS_FORMATS,
|
||||
SUPPORT_CLAMP_ZERO,
|
||||
SUPPORT_LIGHTEN,
|
||||
SUPPORT_MAX_ENUM
|
||||
FEATURE_MULTI_CANVAS_FORMATS,
|
||||
FEATURE_CLAMP_ZERO,
|
||||
FEATURE_LIGHTEN,
|
||||
FEATURE_MAX_ENUM
|
||||
};
|
||||
|
||||
enum Renderer
|
||||
@@ -291,8 +291,8 @@ public:
|
||||
static bool getConstant(const char *in, CompareMode &out);
|
||||
static bool getConstant(CompareMode in, const char *&out);
|
||||
|
||||
static bool getConstant(const char *in, Support &out);
|
||||
static bool getConstant(Support in, const char *&out);
|
||||
static bool getConstant(const char *in, Feature &out);
|
||||
static bool getConstant(Feature in, const char *&out);
|
||||
|
||||
static bool getConstant(const char *in, SystemLimit &out);
|
||||
static bool getConstant(SystemLimit in, const char *&out);
|
||||
@@ -329,8 +329,8 @@ private:
|
||||
static StringMap<CompareMode, COMPARE_MAX_ENUM>::Entry compareModeEntries[];
|
||||
static StringMap<CompareMode, COMPARE_MAX_ENUM> compareModes;
|
||||
|
||||
static StringMap<Support, SUPPORT_MAX_ENUM>::Entry supportEntries[];
|
||||
static StringMap<Support, SUPPORT_MAX_ENUM> support;
|
||||
static StringMap<Feature, FEATURE_MAX_ENUM>::Entry featureEntries[];
|
||||
static StringMap<Feature, FEATURE_MAX_ENUM> features;
|
||||
|
||||
static StringMap<SystemLimit, LIMIT_MAX_ENUM>::Entry systemLimitEntries[];
|
||||
static StringMap<SystemLimit, LIMIT_MAX_ENUM> systemLimits;
|
||||
|
||||
@@ -352,7 +352,7 @@ bool Canvas::setWrap(const Texture::Wrap &w)
|
||||
wrap = w;
|
||||
|
||||
if ((GLAD_ES_VERSION_2_0 && !(GLAD_ES_VERSION_3_0 || GLAD_OES_texture_npot))
|
||||
&& (width != next_p2(width) || height != next_p2(height)))
|
||||
&& (width != nextP2(width) || height != nextP2(height)))
|
||||
{
|
||||
if (wrap.s != WRAP_CLAMP || wrap.t != WRAP_CLAMP)
|
||||
success = false;
|
||||
@@ -552,14 +552,18 @@ bool Canvas::checkCreateStencil()
|
||||
gl.bindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
||||
GLenum format = GL_STENCIL_INDEX8;
|
||||
GLenum attachment = GL_STENCIL_ATTACHMENT;
|
||||
std::vector<GLenum> attachments = {GL_STENCIL_ATTACHMENT};
|
||||
|
||||
// Prefer a combined depth/stencil buffer.
|
||||
if (GLAD_ES_VERSION_3_0 || GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object
|
||||
|| GLAD_EXT_packed_depth_stencil || GLAD_OES_packed_depth_stencil)
|
||||
if (GLAD_ES_VERSION_3_0 || GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object)
|
||||
{
|
||||
format = GL_DEPTH24_STENCIL8;
|
||||
attachment = GL_DEPTH_STENCIL_ATTACHMENT;
|
||||
attachments = {GL_DEPTH_STENCIL_ATTACHMENT};
|
||||
}
|
||||
else if (GLAD_EXT_packed_depth_stencil || GLAD_OES_packed_depth_stencil)
|
||||
{
|
||||
format = GL_DEPTH24_STENCIL8;
|
||||
attachments = {GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT};
|
||||
}
|
||||
|
||||
glGenRenderbuffers(1, &depth_stencil);
|
||||
@@ -570,8 +574,9 @@ bool Canvas::checkCreateStencil()
|
||||
else
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, format, width, height);
|
||||
|
||||
// Attach the stencil buffer to the framebuffer object.
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, depth_stencil);
|
||||
// Attach the buffer to the framebuffer object.
|
||||
for (GLenum attachment : attachments)
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, depth_stencil);
|
||||
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ public:
|
||||
uint32 getTextureCacheID() const;
|
||||
|
||||
static bool getConstant(const char *in, AlignMode &out);
|
||||
static bool getConstant(AlignMode in, const char *&out);
|
||||
static bool getConstant(AlignMode in, const char *&out);
|
||||
|
||||
static int fontCount;
|
||||
|
||||
|
||||
@@ -1103,7 +1103,7 @@ void Graphics::setBlendMode(BlendMode mode, BlendAlpha alphamode)
|
||||
|
||||
if (mode == BLEND_LIGHTEN || mode == BLEND_DARKEN)
|
||||
{
|
||||
if (!isSupported(SUPPORT_LIGHTEN))
|
||||
if (!isSupported(FEATURE_LIGHTEN))
|
||||
throw love::Exception("The 'lighten' and 'darken' blend modes are not supported on this system.");
|
||||
}
|
||||
|
||||
@@ -1677,15 +1677,15 @@ double Graphics::getSystemLimit(SystemLimit limittype) const
|
||||
}
|
||||
}
|
||||
|
||||
bool Graphics::isSupported(Support feature) const
|
||||
bool Graphics::isSupported(Feature feature) const
|
||||
{
|
||||
switch (feature)
|
||||
{
|
||||
case SUPPORT_MULTI_CANVAS_FORMATS:
|
||||
case FEATURE_MULTI_CANVAS_FORMATS:
|
||||
return Canvas::isMultiFormatMultiCanvasSupported();
|
||||
case SUPPORT_CLAMP_ZERO:
|
||||
case FEATURE_CLAMP_ZERO:
|
||||
return gl.isClampZeroTextureWrapSupported();
|
||||
case SUPPORT_LIGHTEN:
|
||||
case FEATURE_LIGHTEN:
|
||||
return GLAD_VERSION_1_4 || GLAD_ES_VERSION_3_0 || GLAD_EXT_blend_minmax;
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -468,7 +468,7 @@ public:
|
||||
/**
|
||||
* Gets whether a graphics feature is supported on this system.
|
||||
**/
|
||||
bool isSupported(Support feature) const;
|
||||
bool isSupported(Feature feature) const;
|
||||
|
||||
void push(StackType type = STACK_TRANSFORM);
|
||||
void pop();
|
||||
|
||||
@@ -308,7 +308,7 @@ bool Image::loadVolatile()
|
||||
|
||||
// NPOT textures don't support mipmapping without full NPOT support.
|
||||
if ((GLAD_ES_VERSION_2_0 && !(GLAD_ES_VERSION_3_0 || GLAD_OES_texture_npot))
|
||||
&& (width != next_p2(width) || height != next_p2(height)))
|
||||
&& (width != nextP2(width) || height != nextP2(height)))
|
||||
{
|
||||
flags.mipmaps = false;
|
||||
filter.mipmap = FILTER_NONE;
|
||||
@@ -519,7 +519,7 @@ bool Image::setWrap(const Texture::Wrap &w)
|
||||
wrap = w;
|
||||
|
||||
if ((GLAD_ES_VERSION_2_0 && !(GLAD_ES_VERSION_3_0 || GLAD_OES_texture_npot))
|
||||
&& (width != next_p2(width) || height != next_p2(height)))
|
||||
&& (width != nextP2(width) || height != nextP2(height)))
|
||||
{
|
||||
if (wrap.s != WRAP_CLAMP || wrap.t != WRAP_CLAMP)
|
||||
success = false;
|
||||
|
||||
@@ -199,6 +199,17 @@ public:
|
||||
return program;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *getScratchBuffer(size_t count)
|
||||
{
|
||||
size_t bytes = sizeof(T) * count;
|
||||
|
||||
if (scratchBuffer.size() < bytes)
|
||||
scratchBuffer.resize(bytes);
|
||||
|
||||
return (T *) scratchBuffer.data();
|
||||
}
|
||||
|
||||
static std::string getGLSLVersion();
|
||||
static bool isSupported();
|
||||
|
||||
@@ -276,6 +287,8 @@ private:
|
||||
|
||||
GLuint videoTextureUnits[3];
|
||||
|
||||
std::vector<char> scratchBuffer;
|
||||
|
||||
// Counts total number of textures bound to each texture unit in all shaders
|
||||
static std::vector<int> textureCounters;
|
||||
|
||||
|
||||
@@ -1387,11 +1387,11 @@ int w_setDefaultShaderCode(lua_State *L)
|
||||
|
||||
int w_getSupported(lua_State *L)
|
||||
{
|
||||
lua_createtable(L, 0, (int) Graphics::SUPPORT_MAX_ENUM);
|
||||
lua_createtable(L, 0, (int) Graphics::FEATURE_MAX_ENUM);
|
||||
|
||||
for (int i = 0; i < (int) Graphics::SUPPORT_MAX_ENUM; i++)
|
||||
for (int i = 0; i < (int) Graphics::FEATURE_MAX_ENUM; i++)
|
||||
{
|
||||
Graphics::Support feature = (Graphics::Support) i;
|
||||
auto feature = (Graphics::Feature) i;
|
||||
const char *name = nullptr;
|
||||
|
||||
if (!Graphics::getConstant(feature, name))
|
||||
|
||||
@@ -47,10 +47,10 @@ int w_Shader_getWarnings(lua_State *L)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T *_getScalars(lua_State *L, int count, size_t &dimension)
|
||||
static T *_getScalars(lua_State *L, Shader *shader, int count, size_t &dimension)
|
||||
{
|
||||
dimension = 1;
|
||||
T *values = new T[count];
|
||||
T *values = shader->getScratchBuffer<T>(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
@@ -60,7 +60,6 @@ static T *_getScalars(lua_State *L, int count, size_t &dimension)
|
||||
values[i] = static_cast<T>(lua_toboolean(L, 3 + i));
|
||||
else
|
||||
{
|
||||
delete[] values;
|
||||
luax_typerror(L, 3 + i, "number or boolean");
|
||||
return 0;
|
||||
}
|
||||
@@ -70,24 +69,22 @@ static T *_getScalars(lua_State *L, int count, size_t &dimension)
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T *_getVectors(lua_State *L, int count, size_t &dimension)
|
||||
static T *_getVectors(lua_State *L, Shader *shader, int count, size_t &dimension)
|
||||
{
|
||||
dimension = luax_objlen(L, 3);
|
||||
T *values = new T[count * dimension];
|
||||
T *values = shader->getScratchBuffer<T>(count * dimension);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
if (!lua_istable(L, 3 + i))
|
||||
{
|
||||
delete[] values;
|
||||
luax_typerror(L, 3 + i, "table");
|
||||
return 0;
|
||||
}
|
||||
if (luax_objlen(L, 3 + i) != dimension)
|
||||
{
|
||||
delete[] values;
|
||||
luaL_error(L, "Error in argument %d: Expected table size %d, got %d.",
|
||||
3+i, dimension, luax_objlen(L, 3+i));
|
||||
3+i, dimension, luax_objlen(L, 3+i));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -100,7 +97,6 @@ static T *_getVectors(lua_State *L, int count, size_t &dimension)
|
||||
values[i * dimension + k - 1] = static_cast<T>(lua_toboolean(L, -1));
|
||||
else
|
||||
{
|
||||
delete[] values;
|
||||
luax_typerror(L, -1, "number or boolean");
|
||||
return 0;
|
||||
}
|
||||
@@ -124,31 +120,16 @@ int w_Shader_sendInt(lua_State *L)
|
||||
size_t dimension = 1;
|
||||
|
||||
if (lua_isnumber(L, 3) || lua_isboolean(L, 3))
|
||||
values = _getScalars<int>(L, count, dimension);
|
||||
values = _getScalars<int>(L, shader, count, dimension);
|
||||
else if (lua_istable(L, 3))
|
||||
values = _getVectors<int>(L, count, dimension);
|
||||
values = _getVectors<int>(L, shader, count, dimension);
|
||||
else
|
||||
return luax_typerror(L, 3, "number, boolean, or table");
|
||||
|
||||
if (!values)
|
||||
return luaL_error(L, "Error in arguments.");
|
||||
|
||||
bool should_error = false;
|
||||
try
|
||||
{
|
||||
shader->sendInt(name, (int) dimension, values, count);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
should_error = true;
|
||||
lua_pushstring(L, e.what());
|
||||
}
|
||||
|
||||
delete[] values;
|
||||
|
||||
if (should_error)
|
||||
return luaL_error(L, "%s", lua_tostring(L, -1));
|
||||
|
||||
luax_catchexcept(L, [&]() { shader->sendInt(name, (int) dimension, values, count); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -165,9 +146,9 @@ static int w__Shader_sendFloat(lua_State *L, bool colors)
|
||||
size_t dimension = 1;
|
||||
|
||||
if (lua_isnumber(L, 3) || lua_isboolean(L, 3))
|
||||
values = _getScalars<float>(L, count, dimension);
|
||||
values = _getScalars<float>(L, shader, count, dimension);
|
||||
else if (lua_istable(L, 3))
|
||||
values = _getVectors<float>(L, count, dimension);
|
||||
values = _getVectors<float>(L, shader, count, dimension);
|
||||
else
|
||||
return luax_typerror(L, 3, "number, boolean, or table");
|
||||
|
||||
@@ -187,22 +168,7 @@ static int w__Shader_sendFloat(lua_State *L, bool colors)
|
||||
}
|
||||
}
|
||||
|
||||
bool should_error = false;
|
||||
try
|
||||
{
|
||||
shader->sendFloat(name, (int) dimension, values, count);
|
||||
}
|
||||
catch (love::Exception &e)
|
||||
{
|
||||
should_error = true;
|
||||
lua_pushstring(L, e.what());
|
||||
}
|
||||
|
||||
delete[] values;
|
||||
|
||||
if (should_error)
|
||||
return luaL_error(L, "%s", lua_tostring(L, -1));
|
||||
|
||||
luax_catchexcept(L, [&]() { shader->sendFloat(name, (int) dimension, values, count); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -248,7 +214,7 @@ int w_Shader_sendMatrix(lua_State *L)
|
||||
return luaL_error(L, "Invalid matrix size: %dx%d (only 2x2, 3x3 and 4x4 matrices are supported).",
|
||||
dimension, dimension);
|
||||
|
||||
float *values = new float[dimension * dimension * count];
|
||||
float *values = shader->getScratchBuffer<float>(dimension * dimension * count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
@@ -272,9 +238,8 @@ int w_Shader_sendMatrix(lua_State *L)
|
||||
// a dimension of mind. You're moving into a land of both shadow
|
||||
// and substance, of things and ideas. You've just crossed over
|
||||
// into... the Twilight Zone.
|
||||
delete[] values;
|
||||
return luaL_error(L, "Invalid matrix size at argument %d: Expected size %dx%d, got %dx%d.",
|
||||
3+i, dimension, dimension, other_dimension, other_dimension);
|
||||
3+i, dimension, dimension, other_dimension, other_dimension);
|
||||
}
|
||||
|
||||
if (table_of_tables)
|
||||
@@ -307,11 +272,7 @@ int w_Shader_sendMatrix(lua_State *L)
|
||||
}
|
||||
}
|
||||
|
||||
luax_catchexcept(L,
|
||||
[&]() { shader->sendMatrix(name, dimension, values, count); },
|
||||
[&](bool) { delete[] values; }
|
||||
);
|
||||
|
||||
luax_catchexcept(L, [&]() { shader->sendMatrix(name, dimension, values, count); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ const char *Timer::getName() const
|
||||
void Timer::sleep(double seconds) const
|
||||
{
|
||||
if (seconds > 0)
|
||||
delay((unsigned int)(seconds*1000));
|
||||
love::sleep((unsigned int)(seconds*1000));
|
||||
}
|
||||
|
||||
} // sdl
|
||||
|
||||
@@ -112,8 +112,7 @@ void Worker::threadFunction()
|
||||
}
|
||||
}
|
||||
|
||||
// sleep
|
||||
love::delay(2);
|
||||
love::sleep(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user