mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
Canvases can now be used in SpriteBatches, ParticleSystems, and Meshes (resolves issue #782).
Canvases and Images are now subclasses of the new Texture class. Added setTexture and getTexture methods for Meshes, ParticleSystems, and SpriteBatches (the old set/getImage methods are deprecated but not removed.) Canvas texture coordinates are no longer flipped.
This commit is contained in:
@@ -21,14 +21,11 @@
|
||||
#ifndef LOVE_GRAPHICS_OPENGL_CANVAS_H
|
||||
#define LOVE_GRAPHICS_OPENGL_CANVAS_H
|
||||
|
||||
#include "graphics/DrawQable.h"
|
||||
#include "graphics/Volatile.h"
|
||||
#include "graphics/Image.h"
|
||||
#include "graphics/Color.h"
|
||||
#include "image/Image.h"
|
||||
#include "image/ImageData.h"
|
||||
#include "common/math.h"
|
||||
#include "common/Matrix.h"
|
||||
#include "Texture.h"
|
||||
#include "OpenGL.h"
|
||||
|
||||
namespace love
|
||||
@@ -38,7 +35,7 @@ namespace graphics
|
||||
namespace opengl
|
||||
{
|
||||
|
||||
class Canvas : public DrawQable, public Volatile
|
||||
class Canvas : public Texture
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -52,6 +49,20 @@ public:
|
||||
Canvas(int width, int height, TextureType texture_type = TYPE_NORMAL);
|
||||
virtual ~Canvas();
|
||||
|
||||
// Implements Volatile.
|
||||
virtual bool loadVolatile();
|
||||
virtual void unloadVolatile();
|
||||
|
||||
// Implements Drawable.
|
||||
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||
|
||||
// Implements Texture.
|
||||
virtual void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||
virtual void setFilter(const Texture::Filter &f);
|
||||
virtual void setWrap(const Texture::Wrap &w);
|
||||
virtual GLuint getGLTexture() const;
|
||||
virtual void predraw() const;
|
||||
|
||||
/**
|
||||
* @param canvases A list of other canvases to temporarily attach to this one,
|
||||
* to allow drawing to multiple canvases at once.
|
||||
@@ -62,13 +73,6 @@ public:
|
||||
|
||||
void clear(Color c);
|
||||
|
||||
virtual void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||
|
||||
/**
|
||||
* @copydoc DrawQable::drawq()
|
||||
**/
|
||||
void drawq(Quad *quad, float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
|
||||
|
||||
/**
|
||||
* Create and attach a stencil buffer to this Canvas' framebuffer, if necessary.
|
||||
**/
|
||||
@@ -78,16 +82,10 @@ 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;
|
||||
|
||||
void setWrap(const Image::Wrap &w);
|
||||
Image::Wrap getWrap() const;
|
||||
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
inline const std::vector<Canvas *> &getAttachedCanvases() const
|
||||
{
|
||||
return attachedCanvases;
|
||||
}
|
||||
|
||||
inline GLenum getStatus() const
|
||||
{
|
||||
@@ -99,9 +97,6 @@ public:
|
||||
return texture_type;
|
||||
}
|
||||
|
||||
bool loadVolatile();
|
||||
void unloadVolatile();
|
||||
|
||||
static bool isSupported();
|
||||
static bool isHDRSupported();
|
||||
static bool isMultiCanvasSupported();
|
||||
@@ -115,33 +110,16 @@ public:
|
||||
// The viewport dimensions of the system (default) framebuffer.
|
||||
static OpenGL::Viewport systemViewport;
|
||||
|
||||
GLuint getTextureName() const
|
||||
{
|
||||
return img;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
friend class Shader;
|
||||
|
||||
GLsizei width;
|
||||
GLsizei height;
|
||||
GLuint fbo;
|
||||
GLuint depth_stencil;
|
||||
GLuint img;
|
||||
|
||||
TextureType texture_type;
|
||||
|
||||
Vertex vertices[4];
|
||||
|
||||
GLenum status;
|
||||
|
||||
struct
|
||||
{
|
||||
Image::Filter filter;
|
||||
Image::Wrap wrap;
|
||||
} settings;
|
||||
|
||||
std::vector<Canvas *> attachedCanvases;
|
||||
|
||||
void setupGrab();
|
||||
|
||||
Reference in New Issue
Block a user