Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/text_engine/text.h @ 7355

Last change on this file since 7355 was 7355, checked in by bensch, 18 years ago

orxonox/trunk: works on windows too

File size: 2.6 KB
RevLine 
[4838]1/*!
[5343]2 * @file text.h
3 * @brief Definition of a text Class, that is able to render text.
[7355]4 */
[1853]5
[5343]6#ifndef _TEXT_H
7#define _TEXT_H
[1853]8
[5343]9#include "element_2d.h"
[1853]10
[5343]11#include "glincl.h"
12
13#define  TEXT_ALIGN_LEFT             E2D_ALIGN_LEFT
14#define  TEXT_ALIGN_RIGHT            E2D_ALIGN_RIGHT
15#define  TEXT_ALIGN_CENTER           E2D_ALIGN_CENTER
16#define  TEXT_ALIGN_SCREEN_CENTER    E2D_ALIGN_SCREEN_CENTER
17#define  TEXT_DEFAULT_COLOR          Vector(1.0, 1.0, 1.0)      //!< the default Color (white)
18#define  TEXT_DEFAULT_BLENDING       1.0f                       //!< the default blending of the text, (no blending at all)
19
[5421]20#define  TEXT_DEFAULT_ALIGNMENT      TEXT_ALIGN_LEFT            //!< default alignment
21#define  TEXT_DEFAULT_SIZE           20                         //!< default size of the Text
[5343]22
23
[4838]24// FORWARD DECLARATION
[5343]25class Font;
[5427]26struct SDL_Surface;
[3543]27
[5343]28//! A Struct to handel Texture Coordinates for quads
29struct TexCoord
30{
31  float    minU;              //!< The minimum U-Coordinate
32  float    maxU;              //!< The maximum U-Coordinate
33  float    minV;              //!< The minimum V-Coordinate
34  float    maxV;              //!< The maximum V-Coordinate
35};
[1853]36
[5343]37//! Represents one textElement.
38class Text : public Element2D
39{
40  public:
[7221]41    Text(const std::string& fontFile = "", unsigned int fontSize = TEXT_DEFAULT_SIZE);
[6981]42    virtual ~Text();
[3245]43
[7221]44    void setFont(const std::string& fontFile, unsigned int renderSize);
[5345]45
[7221]46    void setText(const std::string& text);
[5367]47
[5343]48    /** @returns the String this Text displays */
[7221]49    inline const std::string& getText() const { return this->text; };
[5343]50    /** @param blending the blending intensity to set (between 0.0 and 1.0) */
51    inline void setBlending(float blending) { this->blending = blending; };
52    /** sets the Color of the Text to render (values in [0-1]) @param r red @param g green @param b blue */
[5369]53    void setColor(float r, float g, float b) { this->color = Vector(r, g, b); };
[5367]54    /** sets the Size of the Font */
[5768]55    void setSize(float size) { this->setSizeY2D(size); };
[5369]56    /** @returns the Size of the Text */
[5378]57//    void getSize(float &x, float& y) const { return this->size; };
[5343]58
59    virtual void draw() const;
60
61    void debug() const;
62
63  // helpers.
64    static GLuint loadTexture(SDL_Surface* surface, TexCoord* texCoord);
65    static int powerOfTwo(int input);
66
67  private:
68    Font*             font;           //!< Font of this text
69
[7221]70    std::string       text;           //!< The text to display
[5343]71    Vector            color;          //!< The color of the font.
72    float             blending;       //!< The blending intensity.
[1853]73};
74
[5343]75#endif /* _TEXT_H */
Note: See TracBrowser for help on using the repository browser.