Fix Issue #476: Add HDR Canvas (thanks, Alexander Szpakowski!).

* Add `love.graphics.isSupported("hdrcanvas")' to query whether the hardware
  actually supports HDR canvases.

* Add optional third argument to `love.graphics.newCanvas(w,h, type)', where
  `type' is one of "normal" or "hdr" and defaults to "normal". HDR canvases
  use floating point that can have values > 1 to store pixels, allowing for
  HDR rendering and other higher level lighting techniques when combined with
  pixel effects.

* Add `canvas:getType()'.
This commit is contained in:
vrld
2012-10-11 22:22:10 +02:00
parent 7364e52ebc
commit ccdf6e1c00
9 changed files with 148 additions and 35 deletions
+31 -12
View File
@@ -42,19 +42,15 @@ namespace opengl
class Canvas : public DrawQable, public Volatile
{
public:
Canvas(int width, int height);
enum TextureType {
TYPE_NORMAL,
TYPE_HDR,
TYPE_MAX_ENUM
};
Canvas(int width, int height, TextureType texture_type = TYPE_NORMAL);
virtual ~Canvas();
static bool isSupported();
unsigned int getStatus() const
{
return status;
}
static Canvas *current;
static void bindDefaultCanvas();
void startGrab();
void stopGrab();
@@ -78,9 +74,27 @@ public:
int getWidth();
int getHeight();
unsigned int getStatus() const
{
return status;
}
TextureType getTextureType() const
{
return texture_type;
}
bool loadVolatile();
void unloadVolatile();
static bool isSupported();
static bool isHdrSupported();
static bool getConstant(const char *in, TextureType &out);
static bool getConstant(TextureType in, const char *&out);
static Canvas *current;
static void bindDefaultCanvas();
private:
friend class PixelEffect;
GLuint getTextureName() const
@@ -94,6 +108,8 @@ private:
GLuint depth_stencil;
GLuint img;
TextureType texture_type;
vertex vertices[4];
GLenum status;
@@ -101,10 +117,13 @@ private:
struct
{
Image::Filter filter;
Image::Wrap wrap;
Image::Wrap wrap;
} settings;
void drawv(const Matrix &t, const vertex *v) const;
static StringMap<TextureType, TYPE_MAX_ENUM>::Entry textureTypeEntries[];
static StringMap<TextureType, TYPE_MAX_ENUM> textureTypes;
};
} // opengl