Added MRT support to canvases via love.graphics.setCanvases(c1, c2, ...), and an 'effects' callback function in shaders.

- Simultanious rendering to multiple canvases requires all canvases to be the same size (limitation of pre-GL3.0 framebuffers)
- love.graphics.isSupported("mrtcanvas") was added
- love_Canvases[n] (0-based array of active canvases) can be written to in pixel shaders in the 'effects' callback function
- everything drawn to multiple canvases at once will be duplicated to all canvases if no shader is active or the standard 'effect' shader function is used

--HG--
branch : MRTs
This commit is contained in:
Alex Szpakowski
2013-03-24 02:20:15 -03:00
parent 2009124cf9
commit 2ea065c68b
9 changed files with 377 additions and 87 deletions
+19 -4
View File
@@ -21,6 +21,7 @@
#ifndef LOVE_GRAPHICS_OPENGL_CANVAS_H
#define LOVE_GRAPHICS_OPENGL_CANVAS_H
// LOVE
#include "graphics/DrawQable.h"
#include "graphics/Volatile.h"
#include "graphics/Image.h"
@@ -31,6 +32,9 @@
#include "common/Matrix.h"
#include "OpenGL.h"
// STL
#include <vector>
namespace love
{
namespace graphics
@@ -50,7 +54,11 @@ public:
Canvas(int width, int height, TextureType texture_type = TYPE_NORMAL);
virtual ~Canvas();
void startGrab();
/**
* @param canvases A list of other canvases to temporarily attach to this one,
* to allow drawing to multiple canvases at once.
**/
void startGrab(const std::vector<Canvas *> &canvases);
void stopGrab();
void clear(const Color &c);
@@ -66,6 +74,8 @@ public:
void getPixel(unsigned char* pixel_rgba, int x, int y);
const std::vector<Canvas *> &getAttachedCanvases() const;
void setFilter(const Image::Filter &f);
Image::Filter getFilter() const;
@@ -89,20 +99,22 @@ public:
void unloadVolatile();
static bool isSupported();
static bool isHdrSupported();
static bool isHDRSupported();
static bool isMRTSupported();
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 Shader;
GLuint getTextureName() const
{
return img;
}
private:
friend class Shader;
GLsizei width;
GLsizei height;
GLuint fbo;
@@ -121,6 +133,9 @@ private:
Image::Wrap wrap;
} settings;
std::vector<Canvas *> attachedCanvases;
void startGrab();
void drawv(const Matrix &t, const vertex *v) const;
static StringMap<TextureType, TYPE_MAX_ENUM>::Entry textureTypeEntries[];