Texture.h 989 Bytes
Newer Older
1 2 3
#ifndef TEXTURE_H
#define TEXTURE_H

4 5 6
#if (defined __APPLE__) & (defined __MACH__)
#include <OpenGL/gl.h>
#else
7
#include <GL/gl.h>
8 9
#endif
#include <inttypes.h>
10 11
#include <QSharedPointer>

12 13
#include "WebImage.h"

14 15 16 17 18
class Texture
{
public:
    Texture();

19
    const QString& getSourceURL(void) const;
20 21 22 23 24

    void setID(GLuint id);

    void sync(const WebImagePtr& image);

25 26
    void draw(float x1, float y1, float x2, float y2,
              bool smoothInterpolation) const;
27 28 29
    void draw(float x1, float y1, float x2, float y2,
              float x3, float y3, float x4, float y4,
              bool smoothInterpolation) const;
30 31

private:
32 33 34 35 36 37 38 39
    enum State
    {
        UNINITIALIZED = 0,
        REQUESTED = 1,
        READY = 2
    };

    State state;
40 41
    QString sourceURL;
    GLuint id;
42 43 44 45 46 47 48 49 50 51 52

    int32_t textureWidth;
    int32_t textureHeight;

    int32_t imageWidth;
    int32_t imageHeight;

    float maxU;
    float maxV;
};

53
typedef QSharedPointer<Texture> TexturePtr;
54 55

#endif // TEXTURE_H