mirror of
https://github.com/love2d/love.git
synced 2026-08-19 12:14:20 +02:00
Fixed the winding order of triangles in SpriteBatches and ParticleSystems.
This commit is contained in:
@@ -373,8 +373,8 @@ void VertexIndex::fill()
|
|||||||
indices[i*6+1] = T(i * 4 + 1);
|
indices[i*6+1] = T(i * 4 + 1);
|
||||||
indices[i*6+2] = T(i * 4 + 2);
|
indices[i*6+2] = T(i * 4 + 2);
|
||||||
|
|
||||||
indices[i*6+3] = T(i * 4 + 1);
|
indices[i*6+3] = T(i * 4 + 2);
|
||||||
indices[i*6+4] = T(i * 4 + 2);
|
indices[i*6+4] = T(i * 4 + 1);
|
||||||
indices[i*6+5] = T(i * 4 + 3);
|
indices[i*6+5] = T(i * 4 + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -287,8 +287,8 @@ private:
|
|||||||
* indices[i*6 + 1] = i*4 + 1;
|
* indices[i*6 + 1] = i*4 + 1;
|
||||||
* indices[i*6 + 2] = i*4 + 2;
|
* indices[i*6 + 2] = i*4 + 2;
|
||||||
*
|
*
|
||||||
* indices[i*6 + 3] = i*4 + 1;
|
* indices[i*6 + 3] = i*4 + 2;
|
||||||
* indices[i*6 + 4] = i*4 + 2;
|
* indices[i*6 + 4] = i*4 + 1;
|
||||||
* indices[i*6 + 5] = i*4 + 3;
|
* indices[i*6 + 5] = i*4 + 3;
|
||||||
*
|
*
|
||||||
* There will always be a large enough GLBuffer around until all
|
* There will always be a large enough GLBuffer around until all
|
||||||
|
|||||||
@@ -153,21 +153,17 @@ void Image::loadDefaultTexture()
|
|||||||
setFilter(filter);
|
setFilter(filter);
|
||||||
|
|
||||||
// A nice friendly checkerboard to signify invalid textures...
|
// A nice friendly checkerboard to signify invalid textures...
|
||||||
GLubyte px[] = {0xFF,0xFF,0xFF,0xFF, 0xC0,0xC0,0xC0,0xFF,
|
GLubyte px[] = {0xFF,0xFF,0xFF,0xFF, 0xFF,0xC0,0xC0,0xFF,
|
||||||
0xC0,0xC0,0xC0,0xFF, 0xFF,0xFF,0xFF,0xFF};
|
0xFF,0xC0,0xC0,0xFF, 0xFF,0xFF,0xFF,0xFF};
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, px);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 2, 2, 0, GL_RGBA, GL_UNSIGNED_BYTE, px);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::loadTextureFromCompressedData()
|
void Image::loadFromCompressedData()
|
||||||
{
|
{
|
||||||
GLenum iformat = getCompressedFormat(cdata->getFormat());
|
GLenum iformat = getCompressedFormat(cdata->getFormat());
|
||||||
int count = flags.mipmaps ? cdata->getMipmapCount() : 1;
|
int count = flags.mipmaps ? cdata->getMipmapCount() : 1;
|
||||||
|
|
||||||
// We have to inform OpenGL if the image doesn't have all mipmap levels.
|
|
||||||
if (GLAD_ES_VERSION_3_0 || GLAD_VERSION_1_0)
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, count - 1);
|
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
glCompressedTexImage2D(GL_TEXTURE_2D, i, iformat,
|
glCompressedTexImage2D(GL_TEXTURE_2D, i, iformat,
|
||||||
@@ -176,7 +172,7 @@ void Image::loadTextureFromCompressedData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Image::loadTextureFromImageData()
|
void Image::loadFromImageData()
|
||||||
{
|
{
|
||||||
GLenum iformat = flags.sRGB ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
GLenum iformat = flags.sRGB ? GL_SRGB8_ALPHA8 : GL_RGBA8;
|
||||||
GLenum format = GL_RGBA;
|
GLenum format = GL_RGBA;
|
||||||
@@ -248,8 +244,11 @@ bool Image::loadVolatile()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flags.mipmaps && (GLAD_ES_VERSION_3_0 || GLAD_VERSION_1_0))
|
if ((isCompressed() || !flags.mipmaps) && (GLAD_ES_VERSION_3_0 || GLAD_VERSION_1_0))
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
{
|
||||||
|
int count = (flags.mipmaps && isCompressed()) ? cdata->getMipmapCount() : 1;
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (flags.mipmaps && !isCompressed() &&
|
if (flags.mipmaps && !isCompressed() &&
|
||||||
!(GLAD_ES_VERSION_2_0 || GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
|
!(GLAD_ES_VERSION_2_0 || GLAD_VERSION_3_0 || GLAD_ARB_framebuffer_object))
|
||||||
@@ -264,9 +263,9 @@ bool Image::loadVolatile()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (isCompressed())
|
if (isCompressed())
|
||||||
loadTextureFromCompressedData();
|
loadFromCompressedData();
|
||||||
else
|
else
|
||||||
loadTextureFromImageData();
|
loadFromImageData();
|
||||||
|
|
||||||
GLenum glerr = glGetError();
|
GLenum glerr = glGetError();
|
||||||
if (glerr != GL_NO_ERROR)
|
if (glerr != GL_NO_ERROR)
|
||||||
@@ -327,7 +326,7 @@ bool Image::refresh(int xoffset, int yoffset, int w, int h)
|
|||||||
gl.bindTexture(texture);
|
gl.bindTexture(texture);
|
||||||
|
|
||||||
if (isCompressed())
|
if (isCompressed())
|
||||||
loadTextureFromCompressedData();
|
loadFromCompressedData();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const image::pixel *pdata = (const image::pixel *) data->getData();
|
const image::pixel *pdata = (const image::pixel *) data->getData();
|
||||||
|
|||||||
@@ -144,8 +144,8 @@ private:
|
|||||||
|
|
||||||
void generateMipmaps();
|
void generateMipmaps();
|
||||||
void loadDefaultTexture();
|
void loadDefaultTexture();
|
||||||
void loadTextureFromCompressedData();
|
void loadFromCompressedData();
|
||||||
void loadTextureFromImageData();
|
void loadFromImageData();
|
||||||
|
|
||||||
GLenum getCompressedFormat(image::CompressedData::Format cformat) const;
|
GLenum getCompressedFormat(image::CompressedData::Format cformat) const;
|
||||||
|
|
||||||
|
|||||||
@@ -355,8 +355,8 @@ void Polyline::draw()
|
|||||||
indices[i * 6 + 2] = GLushort(i * 4 + 2);
|
indices[i * 6 + 2] = GLushort(i * 4 + 2);
|
||||||
|
|
||||||
// Second triangle.
|
// Second triangle.
|
||||||
indices[i * 6 + 3] = GLushort(i * 4 + 1);
|
indices[i * 6 + 3] = GLushort(i * 4 + 2);
|
||||||
indices[i * 6 + 4] = GLushort(i * 4 + 2);
|
indices[i * 6 + 4] = GLushort(i * 4 + 1);
|
||||||
indices[i * 6 + 5] = GLushort(i * 4 + 3);
|
indices[i * 6 + 5] = GLushort(i * 4 + 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user