2013-09-01 14:27:21 +00:00
|
|
|
/*
|
|
|
|
** bitmap.h
|
|
|
|
**
|
|
|
|
** This file is part of mkxp.
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
|
|
|
|
**
|
|
|
|
** mkxp is free software: you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation, either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** mkxp is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with mkxp. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BITMAP_H
|
|
|
|
#define BITMAP_H
|
|
|
|
|
|
|
|
#include "disposable.h"
|
|
|
|
#include "etc-internal.h"
|
|
|
|
#include "etc.h"
|
|
|
|
|
2013-12-04 16:48:37 +00:00
|
|
|
#include <sigc++/signal.h>
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
class Font;
|
2013-09-23 05:15:01 +00:00
|
|
|
class ShaderBase;
|
2013-09-06 10:26:41 +00:00
|
|
|
struct TEXFBO;
|
Implement a new tileset atlas layout to allow for bigger tilesets
The atlas packing algorithm has been reworked to pack autotiles
and tileset very efficiently into a texture, splitting the tileset
in multiple ways and eliminating the previous duplication of image
data in the atlas across "frames". Animation, which these frames
were designed for, is now done via duplicated buffer frames,
ie. each animation frame has its own VBO and IBO data. This was
not done to save on VRAM (hardly less memory is used), but to
make place for the new atlas layout.
Thanks to this new layout, even with a max texture size of 2048,
one can use tilesets with up to 15000 height. Of course, such
a tileset couldn't be stored in a regular Bitmap to begin with,
which is why I also introduced a hack called "mega surfaces":
software surfaces stored in RAM and wrapped inside a Bitmap,
whose sole purpose is to be passed to a Tilemap as tilesets.
Various other minor changes and fixes are included.
2013-09-23 20:21:58 +00:00
|
|
|
struct SDL_Surface;
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
struct BitmapPrivate;
|
|
|
|
// FIXME make this class use proper RGSS classes again
|
|
|
|
class Bitmap : public Disposable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Bitmap(const char *filename);
|
|
|
|
Bitmap(int width, int height);
|
|
|
|
/* Clone constructor */
|
|
|
|
Bitmap(const Bitmap &other);
|
|
|
|
~Bitmap();
|
|
|
|
|
|
|
|
int width() const;
|
|
|
|
int height() const;
|
|
|
|
IntRect rect() const;
|
|
|
|
|
|
|
|
void blt(int x, int y,
|
2014-09-23 19:12:58 +00:00
|
|
|
const Bitmap &source, IntRect rect,
|
2013-09-01 14:27:21 +00:00
|
|
|
int opacity = 255);
|
|
|
|
|
|
|
|
void stretchBlt(const IntRect &destRect,
|
2014-09-23 19:12:58 +00:00
|
|
|
const Bitmap &source, const IntRect &sourceRect,
|
2013-09-01 14:27:21 +00:00
|
|
|
int opacity = 255);
|
|
|
|
|
|
|
|
void fillRect(int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
const Vec4 &color);
|
|
|
|
void fillRect(const IntRect &rect, const Vec4 &color);
|
|
|
|
|
|
|
|
void gradientFillRect(int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
const Vec4 &color1, const Vec4 &color2,
|
|
|
|
bool vertical = false);
|
|
|
|
void gradientFillRect(const IntRect &rect,
|
|
|
|
const Vec4 &color1, const Vec4 &color2,
|
|
|
|
bool vertical = false);
|
|
|
|
|
|
|
|
void clearRect(int x, int y,
|
|
|
|
int width, int height);
|
|
|
|
void clearRect(const IntRect &rect);
|
|
|
|
|
2013-10-01 16:10:43 +00:00
|
|
|
void blur();
|
2013-09-04 19:03:59 +00:00
|
|
|
void radialBlur(int angle, int divisions);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
2014-01-31 09:19:16 +00:00
|
|
|
Color getPixel(int x, int y) const;
|
|
|
|
void setPixel(int x, int y, const Color &color);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
|
|
|
void hueChange(int hue);
|
|
|
|
|
|
|
|
enum TextAlign
|
|
|
|
{
|
|
|
|
Left = 0,
|
|
|
|
Center = 1,
|
|
|
|
Right = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
void drawText(int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
const char *str, int align = Left);
|
|
|
|
|
|
|
|
void drawText(const IntRect &rect,
|
|
|
|
const char *str, int align = Left);
|
|
|
|
|
|
|
|
IntRect textSize(const char *str);
|
|
|
|
|
2014-10-25 21:33:41 +00:00
|
|
|
DECL_ATTR(Font, Font&)
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2014-09-04 23:26:03 +00:00
|
|
|
/* Sets initial reference without copying by value,
|
|
|
|
* use at construction */
|
|
|
|
void setInitFont(Font *value);
|
|
|
|
|
2013-09-03 13:21:44 +00:00
|
|
|
/* <internal> */
|
2013-09-06 10:26:41 +00:00
|
|
|
TEXFBO &getGLTypes();
|
2013-09-25 15:07:43 +00:00
|
|
|
SDL_Surface *megaSurface() const;
|
|
|
|
void ensureNonMega() const;
|
2013-09-23 05:15:01 +00:00
|
|
|
|
|
|
|
/* Binds the backing texture and sets the correct
|
|
|
|
* texture size uniform in shader */
|
|
|
|
void bindTex(ShaderBase &shader);
|
2013-09-01 14:27:21 +00:00
|
|
|
|
2014-04-15 17:05:36 +00:00
|
|
|
/* Adds 'rect' to tainted area */
|
|
|
|
void taintArea(const IntRect &rect);
|
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
sigc::signal<void> modified;
|
|
|
|
|
|
|
|
private:
|
2014-09-23 19:12:58 +00:00
|
|
|
void releaseResources();
|
|
|
|
const char *klassName() const { return "bitmap"; }
|
|
|
|
|
2013-09-01 14:27:21 +00:00
|
|
|
BitmapPrivate *p;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // BITMAP_H
|