Added sRGB (gamma-correct) support for Images, Canvases, and the main screen.

love.graphics.newImage(path, “srgb”) creates a new Image whose texels are treated as being in the sRGB color space, so they are linearized when drawing/sampling from the image.

love.graphics.newCanvas(w, h, “srgb”) creates a new Canvas whose texels are treated as being in the sRGB color space, so drawing to the Canvas does a linear->sRGB conversion (but blends linearly), and sampling from it (drawing it or using it in a shader) converts from sRGB to linear space.

The "srgb" window flag does the same as Canvases for the main screen.
This commit is contained in:
Alex Szpakowski
2014-02-02 18:31:41 -04:00
parent 9e746c56fa
commit ce4fdf4ac9
20 changed files with 237 additions and 95 deletions
+10 -3
View File
@@ -56,14 +56,14 @@ public:
*
* @param data The data from which to load the image.
**/
Image(love::image::ImageData *data);
Image(love::image::ImageData *data, Texture::Format format = Texture::FORMAT_NORMAL);
/**
* Creates a new Image with compressed image data.
*
* @param cdata The compressed data from which to load the image.
**/
Image(love::image::CompressedData *cdata);
Image(love::image::CompressedData *cdata, Texture::Format format = Texture::FORMAT_NORMAL);
/**
* Destructor. Deletes the hardware texture and other resources.
@@ -120,6 +120,8 @@ public:
**/
bool refresh();
Texture::Format getFormat() const;
static void setDefaultMipmapSharpness(float sharpness);
static float getDefaultMipmapSharpness();
static void setDefaultMipmapFilter(FilterMode f);
@@ -133,6 +135,8 @@ public:
static bool hasCompressedTextureSupport();
static bool hasCompressedTextureSupport(image::CompressedData::Format format);
static bool hasSRGBSupport();
private:
void uploadDefaultTexture();
@@ -162,6 +166,9 @@ private:
// Whether this Image is using a compressed texture.
bool compressed;
// The format to interpret the texture's data as.
Texture::Format format;
// True if the image wasn't able to be properly created and it had to fall
// back to a default texture.
bool usingDefaultTexture;
@@ -180,7 +187,7 @@ private:
static FilterMode defaultMipmapFilter;
static float defaultMipmapSharpness;
GLenum getCompressedFormat(image::CompressedData::Format format) const;
GLenum getCompressedFormat(image::CompressedData::Format cformat) const;
}; // Image