minetest-mapper-cpp/PixelAttributes.h

49 lines
1.1 KiB
C
Raw Permalink Normal View History

2012-08-25 04:19:58 -07:00
/*
* =====================================================================
* Version: 1.0
* Created: 25.08.2012 10:55:29
* Author: Miroslav Bendík
* Company: LinuxOS.sk
* =====================================================================
*/
#ifndef PIXELATTRIBUTES_H_ADZ35GYF
#define PIXELATTRIBUTES_H_ADZ35GYF
2012-08-25 04:27:40 -07:00
#include <limits>
2012-09-01 05:36:14 -07:00
#include "config.h"
2012-08-25 04:19:58 -07:00
struct PixelAttribute {
2012-08-25 04:27:40 -07:00
PixelAttribute(): height(std::numeric_limits<int>::min()) {};
2012-08-25 04:19:58 -07:00
int height;
2012-08-25 04:27:40 -07:00
inline bool valid_height() {
return height != std::numeric_limits<int>::min();
}
2012-08-25 04:19:58 -07:00
};
class PixelAttributes
{
public:
PixelAttributes();
2012-09-01 05:36:14 -07:00
virtual ~PixelAttributes();
2012-08-25 04:19:58 -07:00
void setWidth(int width);
void scroll();
2012-09-01 05:36:14 -07:00
inline PixelAttribute &attribute(int z, int x) { return m_pixelAttributes[z + 1][x + 1]; };
2012-08-25 04:19:58 -07:00
private:
2012-09-01 05:36:14 -07:00
void freeAttributes();
private:
enum Line {
FirstLine = 0,
LastLine = BLOCK_SIZE,
EmptyLine = BLOCK_SIZE + 1,
2012-09-01 07:17:58 -07:00
LineCount = BLOCK_SIZE + 2
2012-09-01 05:36:14 -07:00
};
PixelAttribute *m_pixelAttributes[BLOCK_SIZE + 2]; // 1px gradient + empty
int m_width;
2012-08-25 04:19:58 -07:00
};
#endif /* end of include guard: PIXELATTRIBUTES_H_ADZ35GYF */