mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
Add mipmapping support to Canvases.
- Added an optional mipmap index argument to the non-table variant of love.graphics.setCanvas, and an optional ‘mipmap’ field to the table variant. - Canvas:setMipmapFilter now works. - Added Canvas:generateMipmaps. - Added Canvas:getMipmapMode. - Added a new ‘mipmaps’ enum field to the table passed into love.graphics.newCanvas. Accepted values are “none” (default), “manual”, and “auto”. If a Canvas has the manual mipmap mode, you will either need to render to a mipmap level or call Canvas:generateMipmaps. If it has the auto mode, mipmaps will be automatically generated after rendering to that Canvas. Generating mipmaps is not free. --HG-- branch : minor
This commit is contained in:
@@ -23,6 +23,8 @@
|
||||
#include "image/Image.h"
|
||||
#include "image/ImageData.h"
|
||||
#include "Texture.h"
|
||||
#include "common/Optional.h"
|
||||
#include "common/StringMap.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -37,38 +39,55 @@ public:
|
||||
|
||||
static love::Type type;
|
||||
|
||||
enum MipmapMode
|
||||
{
|
||||
MIPMAP_NONE,
|
||||
MIPMAP_MANUAL,
|
||||
MIPMAP_AUTO,
|
||||
MIPMAP_MAX_ENUM
|
||||
};
|
||||
|
||||
struct Settings
|
||||
{
|
||||
// Defaults to true for color pixel formats, and false for depth/stencil.
|
||||
struct Readable
|
||||
{
|
||||
bool set = false;
|
||||
bool value = false;
|
||||
};
|
||||
|
||||
int width = 1;
|
||||
int height = 1;
|
||||
int layers = 1; // depth for 3D textures
|
||||
MipmapMode mipmaps = MIPMAP_NONE;
|
||||
PixelFormat format = PIXELFORMAT_NORMAL;
|
||||
TextureType type = TEXTURE_2D;
|
||||
float pixeldensity = 1.0f;
|
||||
int msaa = 0;
|
||||
Readable readable;
|
||||
OptionalBool readable;
|
||||
};
|
||||
|
||||
Canvas(TextureType textype);
|
||||
Canvas(const Settings &settings);
|
||||
virtual ~Canvas();
|
||||
|
||||
virtual love::image::ImageData *newImageData(love::image::Image *module, int slice, int x, int y, int w, int h) = 0;
|
||||
MipmapMode getMipmapMode() const;
|
||||
int getRequestedMSAA() const;
|
||||
|
||||
virtual love::image::ImageData *newImageData(love::image::Image *module, int slice, int mipmap, const Rect &rect) = 0;
|
||||
virtual void generateMipmaps() = 0;
|
||||
|
||||
virtual int getMSAA() const = 0;
|
||||
virtual int getRequestedMSAA() const = 0;
|
||||
virtual ptrdiff_t getRenderTargetHandle() const = 0;
|
||||
|
||||
void draw(Graphics *gfx, Quad *q, const Matrix4 &t) override;
|
||||
void drawLayer(Graphics *gfx, int layer, Quad *q, const Matrix4 &t) override;
|
||||
|
||||
static int canvasCount;
|
||||
|
||||
static bool getConstant(const char *in, MipmapMode &out);
|
||||
static bool getConstant(MipmapMode in, const char *&out);
|
||||
|
||||
protected:
|
||||
|
||||
Settings settings;
|
||||
|
||||
private:
|
||||
|
||||
static StringMap<MipmapMode, MIPMAP_MAX_ENUM>::Entry mipmapEntries[];
|
||||
static StringMap<MipmapMode, MIPMAP_MAX_ENUM> mipmapModes;
|
||||
|
||||
}; // Canvas
|
||||
|
||||
|
||||
Reference in New Issue
Block a user