source: trunk/packages/vizservers/nanovis/R2/include/R2/R2Fonts.h @ 1111

Last change on this file since 1111 was 1111, checked in by gah, 16 years ago

nanovis/heightmap update

File size: 2.0 KB
Line 
1#ifndef __R2_FONTS_H__
2#define __R2_FONTS_H__
3
4#include <R2/R2.h>
5#include <R2/R2Object.h>
6#include <R2/R2string.h>
7#include <vector>
8
9class R2Fonts : public R2Object {
10
11    struct R2FontAttributes {
12        char *_fontName;
13        R2int32 _textureWidth;
14        R2int32 _textureHeight;
15        R2int32 _fontHeight;
16        R2uint32 _fontTextureID;
17        R2uint32 _displayLists;
18       
19        struct R2CharInfo {
20            R2float _left;
21            R2float _right;
22            R2float _top;
23            R2float _bottom;
24            R2bool _valid;
25            R2float _width;
26           
27        };
28        R2CharInfo _chars[256];
29    };
30   
31    typedef std::vector<R2FontAttributes>  R2FontVector;
32
33    R2FontVector        _fonts;
34   
35    /**
36     * @brief current font index
37     */
38    R2int32 _fontIndex;
39   
40    /**
41     * @brief screen width
42     */
43    R2int32 _screenWidth;
44   
45    /**
46     * @brief screen height
47     */
48    R2int32 _screenHeight;
49   
50private :
51    ~R2Fonts();
52   
53    //private :
54public :
55    /**
56     * @brief set projection to orthographic
57     */
58    void begin();
59   
60    /**
61     * @brief reset projection matrix
62     */
63    void end();
64   
65    /**
66     * @brief initialize R2FontAttributes
67     */
68    void initializeFont(R2FontAttributes& attr);
69   
70    /**
71     * @brief load font data
72     */
73    R2bool loadFont(const char* fontName, const char* fontFileName, R2FontAttributes& sFont);
74   
75public :
76    /**
77     * @brief constructor
78     */
79    R2Fonts();
80   
81    /**
82     * @brief
83     */
84    void addFont(const char* fontName, const char* fontFileName);
85   
86    /**
87     * @brief
88     */
89    void setFont(const char* fontName);
90   
91    /**
92     *
93     */
94    void draw(const char* pString, ...) const;
95   
96    /**
97     *
98     */
99    void resize(R2int32 width, R2int32 height);
100   
101    /**
102     * @brief return font height
103     */
104    R2int32 getFontHeight() const;
105   
106};
107
108inline R2int32 R2Fonts::getFontHeight() const
109{
110    return _fonts[_fontIndex]._fontHeight;
111}
112
113#endif // __R2_FONT_H__
114
Note: See TracBrowser for help on using the repository browser.