2010-11-23 04:13:37 +01:00
|
|
|
#ifndef TEXTURE_H
|
|
|
|
#define TEXTURE_H
|
|
|
|
|
2011-08-15 16:06:15 +02:00
|
|
|
#include "declarations.h"
|
2010-11-23 04:13:37 +01:00
|
|
|
|
2011-07-27 01:13:27 +02:00
|
|
|
class Texture : public std::enable_shared_from_this<Texture>
|
2010-11-23 04:13:37 +01:00
|
|
|
{
|
|
|
|
public:
|
2010-11-23 16:30:43 +01:00
|
|
|
/// Create a texture, width and height must be a multiple of 2
|
2011-08-15 21:15:49 +02:00
|
|
|
Texture();
|
2011-08-14 04:09:11 +02:00
|
|
|
Texture(int width, int height, int channels, uchar* pixels = NULL);
|
2010-11-23 04:13:37 +01:00
|
|
|
virtual ~Texture();
|
|
|
|
|
|
|
|
/// Enable texture bilinear filter (smooth scaled textures)
|
2011-05-13 01:24:57 +02:00
|
|
|
virtual void enableBilinearFilter();
|
2010-11-23 04:13:37 +01:00
|
|
|
|
2011-04-10 17:37:15 +02:00
|
|
|
/// Get OpenGL texture id
|
2011-08-15 16:06:15 +02:00
|
|
|
virtual uint getId() const { return m_textureId; }
|
2011-04-10 17:37:15 +02:00
|
|
|
|
|
|
|
/// Copy pixels from OpenGL texture
|
2011-08-15 21:15:49 +02:00
|
|
|
std::vector<uint8> getPixels();
|
2010-11-23 04:13:37 +01:00
|
|
|
|
2011-08-15 16:06:15 +02:00
|
|
|
int getWidth() const { return m_size.width(); }
|
|
|
|
int getHeight() const { return m_size.height(); }
|
|
|
|
const Size getSize() const { return m_size; }
|
2011-05-16 20:30:05 +02:00
|
|
|
const Size& getGlSize() const { return m_glSize; }
|
2011-04-10 17:37:15 +02:00
|
|
|
|
2011-08-15 21:15:49 +02:00
|
|
|
bool isEmpty() const { return m_textureId == 0; }
|
|
|
|
|
2011-05-13 01:24:57 +02:00
|
|
|
protected:
|
2011-08-14 04:09:11 +02:00
|
|
|
uint internalLoadGLTexture(uchar* pixels, int channels, int w, int h);
|
2011-05-16 20:30:05 +02:00
|
|
|
|
2011-04-06 22:18:00 +02:00
|
|
|
uint m_textureId;
|
2010-11-25 00:36:15 +01:00
|
|
|
Size m_size;
|
2011-05-16 20:30:05 +02:00
|
|
|
Size m_glSize;
|
2010-11-23 04:13:37 +01:00
|
|
|
};
|
|
|
|
|
2011-08-14 04:09:11 +02:00
|
|
|
#endif
|