Texture.h 2.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2010 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL 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 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief Definition of the class Texture.
 *
 *   @author Lionel Heng <hengli@student.ethz.ch>
 *
 */

32 33 34
#ifndef TEXTURE_H
#define TEXTURE_H

35 36 37
#if (defined __APPLE__) & (defined __MACH__)
#include <OpenGL/gl.h>
#else
38
#include <GL/gl.h>
39 40
#endif
#include <inttypes.h>
41 42
#include <QSharedPointer>

43 44
#include "WebImage.h"

45 46 47 48 49
class Texture
{
public:
    Texture();

50
    const QString& getSourceURL(void) const;
51 52 53 54 55

    void setID(GLuint id);

    void sync(const WebImagePtr& image);

56 57
    void draw(float x1, float y1, float x2, float y2,
              bool smoothInterpolation) const;
58 59 60
    void draw(float x1, float y1, float x2, float y2,
              float x3, float y3, float x4, float y4,
              bool smoothInterpolation) const;
61

62 63
    bool is3D(void) const;

64
private:
65 66 67 68 69 70 71 72
    enum State
    {
        UNINITIALIZED = 0,
        REQUESTED = 1,
        READY = 2
    };

    State state;
73 74
    QString sourceURL;
    GLuint id;
75 76 77 78 79 80 81

    int32_t textureWidth;
    int32_t textureHeight;

    int32_t imageWidth;
    int32_t imageHeight;

82 83 84
    bool _is3D;
    QVector< QVector<int32_t> > heightModel;

85 86 87 88
    float maxU;
    float maxV;
};

89
typedef QSharedPointer<Texture> TexturePtr;
90 91

#endif // TEXTURE_H