mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Merge default into minor
--HG-- branch : minor
This commit is contained in:
@@ -73,6 +73,11 @@ Matrix4::Matrix4()
|
||||
{
|
||||
setIdentity();
|
||||
}
|
||||
|
||||
Matrix4::Matrix4(float t00, float t10, float t01, float t11, float x, float y)
|
||||
{
|
||||
setRawTransformation(t00, t10, t01, t11, x, y);
|
||||
}
|
||||
|
||||
Matrix4::Matrix4(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
@@ -138,6 +143,18 @@ void Matrix4::setShear(float kx, float ky)
|
||||
e[1] = ky;
|
||||
e[4] = kx;
|
||||
}
|
||||
|
||||
void Matrix4::setRawTransformation(float t00, float t10, float t01, float t11, float x, float y)
|
||||
{
|
||||
memset(e, 0, sizeof(float)*16); // zero out matrix
|
||||
e[10] = e[15] = 1.0f;
|
||||
e[0] = t00;
|
||||
e[1] = t10;
|
||||
e[4] = t01;
|
||||
e[5] = t11;
|
||||
e[12] = x;
|
||||
e[13] = y;
|
||||
}
|
||||
|
||||
void Matrix4::setTransformation(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,11 @@ public:
|
||||
* Creates a new identity matrix.
|
||||
**/
|
||||
Matrix4();
|
||||
|
||||
/**
|
||||
* Creates a new matrix with the transform values set.
|
||||
**/
|
||||
Matrix4(float t00, float t10, float t01, float t11, float x, float y);
|
||||
|
||||
/**
|
||||
* Creates a new matrix set to a transformation.
|
||||
@@ -107,6 +112,21 @@ public:
|
||||
* @param ky Shear along y-axis.
|
||||
**/
|
||||
void setShear(float kx, float ky);
|
||||
|
||||
/**
|
||||
* Sets a transformation's values directly. Useful if you want to modify them inplace,
|
||||
* or if you want to create a transformation that's not buildable with setTransformation()
|
||||
* i.e. the inverse of setTransformation() is not easily built with another call
|
||||
* to setTransformation() with tweaked values.
|
||||
*
|
||||
* @param t00 The sx*cos(angle) component of the transformation.
|
||||
* @param t10 The sx*sin(angle) component of the transformation.
|
||||
* @param t01 The sy*(-sin(angle)) component of the transformation.
|
||||
* @param t11 The sy*cos(angle) component of the transformation.
|
||||
* @param x The x translation component of the transformation.
|
||||
* @param y The y translation component of the transformation.
|
||||
**/
|
||||
void setRawTransformation(float t00, float t10, float t01, float t11, float x, float y);
|
||||
|
||||
/**
|
||||
* Creates a transformation with a certain position, orientation, scale
|
||||
|
||||
@@ -712,12 +712,18 @@ static int stbi__sse2_available()
|
||||
|
||||
static int stbi__sse2_available()
|
||||
{
|
||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 // GCC 4.8 or later
|
||||
// GCC 4.8+ has a nice way to do this
|
||||
return __builtin_cpu_supports("sse2");
|
||||
#if defined(STBI__X64_TARGET)
|
||||
// on x64, SSE2 can be assumed to be available.
|
||||
return 1;
|
||||
#elif defined(LOVE_STBI_SSE2_OVERRIDE)
|
||||
return 1;
|
||||
#else
|
||||
// portable way to do this, preferably without using GCC inline ASM?
|
||||
// just bail for now.
|
||||
# warning "stb_image compiled without SSE2 support, define LOVE_STBI_SSE2_OVERRIDE to force SSE2 support"
|
||||
// __builtin_cpu_supports is buggy on GCC 5 and above, causing problems if
|
||||
// referenced in a shared object, giving missing __cpu_model hidden symbol errors.
|
||||
// To get around that, just assume that SSE2 is not available on x86.
|
||||
//
|
||||
// See https://github.com/nothings/stb/issues/280 for more information.
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -242,6 +242,7 @@ void ParticleSystem::initParticle(Particle *p, float t)
|
||||
|
||||
p->position = pos;
|
||||
|
||||
float rand_x, rand_y;
|
||||
switch (areaSpreadDistribution)
|
||||
{
|
||||
case DISTRIBUTION_UNIFORM:
|
||||
@@ -252,6 +253,12 @@ void ParticleSystem::initParticle(Particle *p, float t)
|
||||
p->position.x += (float) rng.randomNormal(areaSpread.getX());
|
||||
p->position.y += (float) rng.randomNormal(areaSpread.getY());
|
||||
break;
|
||||
case DISTRIBUTION_ELLIPSE:
|
||||
rand_x = (float) rng.random(-1, 1);
|
||||
rand_y = (float) rng.random(-1, 1);
|
||||
p->position.x += areaSpread.getX() * (rand_x * sqrt(1 - 0.5f*pow(rand_y, 2)));
|
||||
p->position.y += areaSpread.getY() * (rand_y * sqrt(1 - 0.5f*pow(rand_x, 2)));
|
||||
break;
|
||||
case DISTRIBUTION_NONE:
|
||||
default:
|
||||
break;
|
||||
@@ -949,6 +956,7 @@ StringMap<ParticleSystem::AreaSpreadDistribution, ParticleSystem::DISTRIBUTION_M
|
||||
{ "none", DISTRIBUTION_NONE },
|
||||
{ "uniform", DISTRIBUTION_UNIFORM },
|
||||
{ "normal", DISTRIBUTION_NORMAL },
|
||||
{ "ellipse", DISTRIBUTION_ELLIPSE },
|
||||
};
|
||||
|
||||
StringMap<ParticleSystem::AreaSpreadDistribution, ParticleSystem::DISTRIBUTION_MAX_ENUM> ParticleSystem::distributions(ParticleSystem::distributionsEntries, sizeof(ParticleSystem::distributionsEntries));
|
||||
|
||||
@@ -46,13 +46,14 @@ class ParticleSystem : public Drawable
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Type of distribution new particles are drawn from: None, uniform, normal.
|
||||
* Type of distribution new particles are drawn from: None, uniform, normal, ellipse.
|
||||
*/
|
||||
enum AreaSpreadDistribution
|
||||
{
|
||||
DISTRIBUTION_NONE,
|
||||
DISTRIBUTION_UNIFORM,
|
||||
DISTRIBUTION_NORMAL,
|
||||
DISTRIBUTION_ELLIPSE,
|
||||
DISTRIBUTION_MAX_ENUM
|
||||
};
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ enum KTXGLInternalFormat
|
||||
{
|
||||
KTX_GL_ETC1_RGB8_OES = 0x8D64,
|
||||
|
||||
// ETC2 and EAC.
|
||||
KTX_GL_COMPRESSED_R11_EAC = 0x9270,
|
||||
KTX_GL_COMPRESSED_SIGNED_R11_EAC = 0x9271,
|
||||
KTX_GL_COMPRESSED_RG11_EAC = 0x9272,
|
||||
@@ -78,17 +79,33 @@ enum KTXGLInternalFormat
|
||||
KTX_GL_COMPRESSED_RGBA8_ETC2_EAC = 0x9278,
|
||||
KTX_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279,
|
||||
|
||||
// I don't know if any KTX file contains PVR data, but why not support it.
|
||||
// PVRTC1.
|
||||
KTX_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00,
|
||||
KTX_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01,
|
||||
KTX_GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02,
|
||||
KTX_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03,
|
||||
|
||||
// Same with DXT1/3/5.
|
||||
KTX_GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0,
|
||||
KTX_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2,
|
||||
KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3,
|
||||
// DXT1, DXT3, and DXT5.
|
||||
KTX_GL_COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0,
|
||||
KTX_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2,
|
||||
KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3,
|
||||
KTX_GL_COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C,
|
||||
KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E,
|
||||
KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F,
|
||||
|
||||
// BC4 and BC5.
|
||||
KTX_GL_COMPRESSED_RED_RGTC1 = 0x8DBB,
|
||||
KTX_GL_COMPRESSED_SIGNED_RED_RGTC1 = 0x8DBC,
|
||||
KTX_GL_COMPRESSED_RG_RGTC2 = 0x8DBD,
|
||||
KTX_GL_COMPRESSED_SIGNED_RG_RGTC2 = 0x8DBE,
|
||||
|
||||
// BC6 and BC7.
|
||||
KTX_GL_COMPRESSED_RGBA_BPTC_UNORM = 0x8E8C,
|
||||
KTX_GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM = 0x8E8D,
|
||||
KTX_GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT = 0x8E8E,
|
||||
KTX_GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT = 0x8E8F,
|
||||
|
||||
// ASTC.
|
||||
KTX_GL_COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0,
|
||||
KTX_GL_COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1,
|
||||
KTX_GL_COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2,
|
||||
@@ -129,6 +146,8 @@ CompressedImageData::Format convertFormat(uint32 glformat, bool &sRGB)
|
||||
{
|
||||
case KTX_GL_ETC1_RGB8_OES:
|
||||
return CompressedImageData::FORMAT_ETC1;
|
||||
|
||||
// EAC and ETC2.
|
||||
case KTX_GL_COMPRESSED_R11_EAC:
|
||||
return CompressedImageData::FORMAT_EAC_R;
|
||||
case KTX_GL_COMPRESSED_SIGNED_R11_EAC:
|
||||
@@ -152,6 +171,8 @@ CompressedImageData::Format convertFormat(uint32 glformat, bool &sRGB)
|
||||
case KTX_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
||||
sRGB = true;
|
||||
return CompressedImageData::FORMAT_ETC2_RGBA;
|
||||
|
||||
// PVRTC.
|
||||
case KTX_GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
|
||||
return CompressedImageData::FORMAT_PVR1_RGB4;
|
||||
case KTX_GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
|
||||
@@ -160,12 +181,42 @@ CompressedImageData::Format convertFormat(uint32 glformat, bool &sRGB)
|
||||
return CompressedImageData::FORMAT_PVR1_RGBA4;
|
||||
case KTX_GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
|
||||
return CompressedImageData::FORMAT_PVR1_RGBA2;
|
||||
|
||||
// DXT.
|
||||
case KTX_GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||
sRGB = true;
|
||||
case KTX_GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
|
||||
return CompressedImageData::FORMAT_DXT1;
|
||||
case KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
|
||||
sRGB = true;
|
||||
case KTX_GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
|
||||
return CompressedImageData::FORMAT_DXT3;
|
||||
case KTX_GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||
sRGB = true;
|
||||
case KTX_GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
|
||||
return CompressedImageData::FORMAT_DXT5;
|
||||
|
||||
// BC4 and BC5.
|
||||
case KTX_GL_COMPRESSED_RED_RGTC1:
|
||||
return CompressedImageData::FORMAT_BC4;
|
||||
case KTX_GL_COMPRESSED_SIGNED_RED_RGTC1:
|
||||
return CompressedImageData::FORMAT_BC4s;
|
||||
case KTX_GL_COMPRESSED_RG_RGTC2:
|
||||
return CompressedImageData::FORMAT_BC5;
|
||||
case KTX_GL_COMPRESSED_SIGNED_RG_RGTC2:
|
||||
return CompressedImageData::FORMAT_BC5s;
|
||||
|
||||
// BC6 and BC7.
|
||||
case KTX_GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
|
||||
sRGB = true;
|
||||
case KTX_GL_COMPRESSED_RGBA_BPTC_UNORM:
|
||||
return CompressedImageData::FORMAT_BC7;
|
||||
case KTX_GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:
|
||||
return CompressedImageData::FORMAT_BC6Hs;
|
||||
case KTX_GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
|
||||
return CompressedImageData::FORMAT_BC6H;
|
||||
|
||||
// ASTC.
|
||||
case KTX_GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
|
||||
sRGB = true;
|
||||
case KTX_GL_COMPRESSED_RGBA_ASTC_4x4_KHR:
|
||||
|
||||
@@ -143,6 +143,8 @@ public:
|
||||
virtual void minimize() = 0;
|
||||
virtual void maximize() = 0;
|
||||
|
||||
virtual bool isMaximized() const = 0;
|
||||
|
||||
// default no-op implementation
|
||||
virtual void swapBuffers();
|
||||
|
||||
|
||||
@@ -886,6 +886,11 @@ void Window::maximize()
|
||||
}
|
||||
}
|
||||
|
||||
bool Window::isMaximized() const
|
||||
{
|
||||
return window != nullptr && (SDL_GetWindowFlags(window) & SDL_WINDOW_MAXIMIZED);
|
||||
}
|
||||
|
||||
void Window::swapBuffers()
|
||||
{
|
||||
SDL_GL_SwapWindow(window);
|
||||
|
||||
@@ -76,6 +76,8 @@ public:
|
||||
void minimize();
|
||||
void maximize();
|
||||
|
||||
bool isMaximized() const;
|
||||
|
||||
void swapBuffers();
|
||||
|
||||
bool hasFocus() const;
|
||||
|
||||
@@ -466,6 +466,12 @@ int w_maximize(lua_State *)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_isMaximized(lua_State *L)
|
||||
{
|
||||
luax_pushboolean(L, instance()->isMaximized());
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_showMessageBox(lua_State *L)
|
||||
{
|
||||
Window::MessageBoxData data = {};
|
||||
@@ -567,6 +573,7 @@ static const luaL_Reg functions[] =
|
||||
{ "fromPixels", w_fromPixels },
|
||||
{ "minimize", w_minimize },
|
||||
{ "maximize", w_maximize },
|
||||
{ "isMaximized", w_isMaximized },
|
||||
{ "showMessageBox", w_showMessageBox },
|
||||
{ "requestAttention", w_requestAttention },
|
||||
{ 0, 0 }
|
||||
|
||||
Reference in New Issue
Block a user