mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Added Image:isCompressed()
--HG-- branch : image-CompressedData
This commit is contained in:
@@ -43,7 +43,7 @@ Image::Image(love::image::ImageData *data)
|
|||||||
, texture(0)
|
, texture(0)
|
||||||
, mipmapSharpness(defaultMipmapSharpness)
|
, mipmapSharpness(defaultMipmapSharpness)
|
||||||
, mipmapsCreated(false)
|
, mipmapsCreated(false)
|
||||||
, isCompressed(false)
|
, compressed(false)
|
||||||
{
|
{
|
||||||
data->retain();
|
data->retain();
|
||||||
this->data = data;
|
this->data = data;
|
||||||
@@ -57,7 +57,7 @@ Image::Image(love::image::CompressedData *cdata)
|
|||||||
, texture(0)
|
, texture(0)
|
||||||
, mipmapSharpness(defaultMipmapSharpness)
|
, mipmapSharpness(defaultMipmapSharpness)
|
||||||
, mipmapsCreated(false)
|
, mipmapsCreated(false)
|
||||||
, isCompressed(true)
|
, compressed(true)
|
||||||
{
|
{
|
||||||
cdata->retain();
|
cdata->retain();
|
||||||
this->cdata = cdata;
|
this->cdata = cdata;
|
||||||
@@ -146,7 +146,7 @@ void Image::drawq(love::graphics::Quad *quad, float x, float y, float angle, flo
|
|||||||
|
|
||||||
void Image::uploadCompressedMipmaps()
|
void Image::uploadCompressedMipmaps()
|
||||||
{
|
{
|
||||||
if (!isCompressed || !cdata || !hasCompressedTextureSupport(cdata->getType()))
|
if (!isCompressed() || !cdata || !hasCompressedTextureSupport(cdata->getType()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bind();
|
bind();
|
||||||
@@ -236,7 +236,7 @@ void Image::checkMipmapsCreated()
|
|||||||
if (mipmapsCreated || filter.mipmap == FILTER_NONE)
|
if (mipmapsCreated || filter.mipmap == FILTER_NONE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (isCompressed && cdata && hasCompressedTextureSupport(cdata->getType()))
|
if (isCompressed() && cdata && hasCompressedTextureSupport(cdata->getType()))
|
||||||
uploadCompressedMipmaps();
|
uploadCompressedMipmaps();
|
||||||
else if (data)
|
else if (data)
|
||||||
createMipmaps();
|
createMipmaps();
|
||||||
@@ -340,7 +340,7 @@ void Image::unload()
|
|||||||
|
|
||||||
bool Image::loadVolatile()
|
bool Image::loadVolatile()
|
||||||
{
|
{
|
||||||
if (isCompressed && cdata && !hasCompressedTextureSupport(cdata->getType()))
|
if (isCompressed() && cdata && !hasCompressedTextureSupport(cdata->getType()))
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
if (image::CompressedData::getConstant(cdata->getType(), str))
|
if (image::CompressedData::getConstant(cdata->getType(), str))
|
||||||
@@ -381,7 +381,7 @@ bool Image::loadVolatilePOT()
|
|||||||
|
|
||||||
while (glGetError() != GL_NO_ERROR); // clear errors
|
while (glGetError() != GL_NO_ERROR); // clear errors
|
||||||
|
|
||||||
if (isCompressed && cdata)
|
if (isCompressed() && cdata)
|
||||||
{
|
{
|
||||||
if (s < 1.0f || t < 1.0f)
|
if (s < 1.0f || t < 1.0f)
|
||||||
{
|
{
|
||||||
@@ -442,7 +442,7 @@ bool Image::loadVolatileNPOT()
|
|||||||
|
|
||||||
while (glGetError() != GL_NO_ERROR); // clear errors
|
while (glGetError() != GL_NO_ERROR); // clear errors
|
||||||
|
|
||||||
if (isCompressed && cdata)
|
if (isCompressed() && cdata)
|
||||||
{
|
{
|
||||||
GLenum format = getCompressedFormat(cdata->getType());
|
GLenum format = getCompressedFormat(cdata->getType());
|
||||||
glCompressedTexImage2DARB(GL_TEXTURE_2D,
|
glCompressedTexImage2DARB(GL_TEXTURE_2D,
|
||||||
@@ -527,6 +527,11 @@ Image::FilterMode Image::getDefaultMipmapFilter()
|
|||||||
return defaultMipmapFilter;
|
return defaultMipmapFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Image::isCompressed() const
|
||||||
|
{
|
||||||
|
return compressed;
|
||||||
|
}
|
||||||
|
|
||||||
GLenum Image::getCompressedFormat(image::CompressedData::TextureType type) const
|
GLenum Image::getCompressedFormat(image::CompressedData::TextureType type) const
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
|
|||||||
@@ -115,6 +115,11 @@ public:
|
|||||||
void setMipmapSharpness(float sharpness);
|
void setMipmapSharpness(float sharpness);
|
||||||
float getMipmapSharpness() const;
|
float getMipmapSharpness() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this Image is using a compressed texture (via CompressedData).
|
||||||
|
**/
|
||||||
|
bool isCompressed() const;
|
||||||
|
|
||||||
void bind() const;
|
void bind() const;
|
||||||
|
|
||||||
bool load();
|
bool load();
|
||||||
@@ -170,7 +175,8 @@ private:
|
|||||||
// True if mipmaps have been created for this Image.
|
// True if mipmaps have been created for this Image.
|
||||||
bool mipmapsCreated;
|
bool mipmapsCreated;
|
||||||
|
|
||||||
bool isCompressed;
|
// Whether this Image is using a compressed texture.
|
||||||
|
bool compressed;
|
||||||
|
|
||||||
// The image's filter mode
|
// The image's filter mode
|
||||||
Image::Filter filter;
|
Image::Filter filter;
|
||||||
|
|||||||
@@ -175,6 +175,13 @@ int w_Image_getWrap(lua_State *L)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w_Image_isCompressed(lua_State *L)
|
||||||
|
{
|
||||||
|
Image *i = luax_checkimage(L, 1);
|
||||||
|
luax_pushboolean(L, i->isCompressed());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static const luaL_Reg functions[] =
|
static const luaL_Reg functions[] =
|
||||||
{
|
{
|
||||||
{ "getWidth", w_Image_getWidth },
|
{ "getWidth", w_Image_getWidth },
|
||||||
@@ -186,6 +193,7 @@ static const luaL_Reg functions[] =
|
|||||||
{ "getWrap", w_Image_getWrap },
|
{ "getWrap", w_Image_getWrap },
|
||||||
{ "setMipmapFilter", w_Image_setMipmapFilter },
|
{ "setMipmapFilter", w_Image_setMipmapFilter },
|
||||||
{ "getMipmapFilter", w_Image_getMipmapFilter },
|
{ "getMipmapFilter", w_Image_getMipmapFilter },
|
||||||
|
{ "isCompressed", w_Image_isCompressed },
|
||||||
{ 0, 0 }
|
{ 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ int w_Image_setMipmapFilter(lua_State *L);
|
|||||||
int w_Image_getMipmapFilter(lua_State *L);
|
int w_Image_getMipmapFilter(lua_State *L);
|
||||||
int w_Image_setWrap(lua_State *L);
|
int w_Image_setWrap(lua_State *L);
|
||||||
int w_Image_getWrap(lua_State *L);
|
int w_Image_getWrap(lua_State *L);
|
||||||
|
int w_Image_isCompressed(lua_State *L);
|
||||||
extern "C" int luaopen_image(lua_State *L);
|
extern "C" int luaopen_image(lua_State *L);
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
Reference in New Issue
Block a user