~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to PsychSourceGL/Cohorts/FTGLTextRenderer/FTGL/FTGlyph.h

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * FTGL - OpenGL font library
 
3
 *
 
4
 * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
 
5
 * Copyright (c) 2008 Sam Hocevar <sam@zoy.org>
 
6
 * Copyright (c) 2008 Sean Morrison <learner@brlcad.org>
 
7
 *
 
8
 * Permission is hereby granted, free of charge, to any person obtaining
 
9
 * a copy of this software and associated documentation files (the
 
10
 * "Software"), to deal in the Software without restriction, including
 
11
 * without limitation the rights to use, copy, modify, merge, publish,
 
12
 * distribute, sublicense, and/or sell copies of the Software, and to
 
13
 * permit persons to whom the Software is furnished to do so, subject to
 
14
 * the following conditions:
 
15
 *
 
16
 * The above copyright notice and this permission notice shall be
 
17
 * included in all copies or substantial portions of the Software.
 
18
 *
 
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
20
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
21
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
22
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 
23
 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
24
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
25
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
26
 */
 
27
 
 
28
#ifndef __ftgl__
 
29
#   include <FTGL/ftgles.h>
 
30
#endif
 
31
 
 
32
#ifndef __FTGlyph__
 
33
#define __FTGlyph__
 
34
 
 
35
#ifdef __cplusplus
 
36
 
 
37
class FTGlyphImpl;
 
38
 
 
39
/**
 
40
 * FTGlyph is the base class for FTGL glyphs.
 
41
 *
 
42
 * It provides the interface between Freetype glyphs and their openGL
 
43
 * renderable counterparts. This is an abstract class and derived classes
 
44
 * must implement the <code>Render</code> function.
 
45
 *
 
46
 * @see FTBBox
 
47
 * @see FTPoint
 
48
 */
 
49
class FTGL_EXPORT FTGlyph
 
50
{
 
51
    protected:
 
52
        /**
 
53
         * Create a glyph.
 
54
         *
 
55
         * @param glyph  The Freetype glyph to be processed
 
56
         */
 
57
        FTGlyph(FT_GlyphSlot glyph);
 
58
 
 
59
    private:
 
60
        /**
 
61
         * Internal FTGL FTGlyph constructor. For private use only.
 
62
         *
 
63
         * @param pImpl  Internal implementation object. Will be destroyed
 
64
         *               upon FTGlyph deletion.
 
65
         */
 
66
        FTGlyph(FTGlyphImpl *pImpl);
 
67
 
 
68
        /* Allow our internal subclasses to access the private constructor */
 
69
        friend class FTBitmapGlyph;
 
70
        friend class FTBufferGlyph;
 
71
        //friend class FTExtrudeGlyph;
 
72
        friend class FTOutlineGlyph;
 
73
        friend class FTPixmapGlyph;
 
74
        friend class FTPolygonGlyph;
 
75
        friend class FTTextureGlyph;
 
76
 
 
77
    public:
 
78
        /**
 
79
          * Destructor
 
80
          */
 
81
        virtual ~FTGlyph();
 
82
 
 
83
        /**
 
84
         * Renders this glyph at the current pen position.
 
85
         *
 
86
         * @param pen  The current pen position.
 
87
         * @param renderMode  Render mode to display
 
88
         * @return  The advance distance for this glyph.
 
89
         */
 
90
        virtual const FTPoint& Render(const FTPoint& pen, int renderMode) = 0;
 
91
 
 
92
        /**
 
93
         * Return the advance width for this glyph.
 
94
         *
 
95
         * @return  advance width.
 
96
         */
 
97
        virtual float Advance() const;
 
98
 
 
99
        /**
 
100
         * Return the bounding box for this glyph.
 
101
         *
 
102
         * @return  bounding box.
 
103
         */
 
104
        virtual const FTBBox& BBox() const;
 
105
 
 
106
        /**
 
107
         * Queries for errors.
 
108
         *
 
109
         * @return  The current error code.
 
110
         */
 
111
        virtual FT_Error Error() const;
 
112
 
 
113
    private:
 
114
        /**
 
115
         * Internal FTGL FTGlyph implementation object. For private use only.
 
116
         */
 
117
        FTGlyphImpl *impl;
 
118
};
 
119
 
 
120
#endif //__cplusplus
 
121
 
 
122
FTGL_BEGIN_C_DECLS
 
123
 
 
124
/**
 
125
 * FTGLglyph is the base class for FTGL glyphs.
 
126
 *
 
127
 * It provides the interface between Freetype glyphs and their openGL
 
128
 * renderable counterparts. This is an abstract class and derived classes
 
129
 * must implement the ftglRenderGlyph() function.
 
130
 */
 
131
struct _FTGLGlyph;
 
132
typedef struct _FTGLglyph FTGLglyph;
 
133
 
 
134
/**
 
135
 * Create a custom FTGL glyph object.
 
136
 * FIXME: maybe get rid of "base" and have advanceCallback etc. functions
 
137
 *
 
138
 * @param base  The base FTGLglyph* to subclass.
 
139
 * @param data  A pointer to private data that will be passed to callbacks.
 
140
 * @param renderCallback  A rendering callback function.
 
141
 * @param destroyCallback  A callback function to be called upon destruction.
 
142
 * @return  An FTGLglyph* object.
 
143
 */
 
144
FTGL_EXPORT FTGLglyph *ftglCreateCustomGlyph(FTGLglyph *base, void *data,
 
145
    void (*renderCallback) (FTGLglyph *, void *, FTGL_DOUBLE, FTGL_DOUBLE,
 
146
                             int, FTGL_DOUBLE *, FTGL_DOUBLE *),
 
147
    void (*destroyCallback) (FTGLglyph *, void *));
 
148
 
 
149
/**
 
150
 * Destroy an FTGL glyph object.
 
151
 *
 
152
 * @param glyph  An FTGLglyph* object.
 
153
 */
 
154
FTGL_EXPORT void ftglDestroyGlyph(FTGLglyph *glyph);
 
155
 
 
156
/**
 
157
 * Render a glyph at the current pen position and compute the corresponding
 
158
 * advance.
 
159
 *
 
160
 * @param glyph  An FTGLglyph* object.
 
161
 * @param penx  The current pen's X position.
 
162
 * @param peny  The current pen's Y position.
 
163
 * @param renderMode  Render mode to display
 
164
 * @param advancex  A pointer to an FTGL_DOUBLE where to write the advance's X
 
165
 *                  component.
 
166
 * @param advancey  A pointer to an FTGL_DOUBLE where to write the advance's Y
 
167
 *                  component.
 
168
 */
 
169
FTGL_EXPORT void ftglRenderGlyph(FTGLglyph *glyph, FTGL_DOUBLE penx,
 
170
                                 FTGL_DOUBLE peny, int renderMode,
 
171
                                 FTGL_DOUBLE *advancex, FTGL_DOUBLE *advancey);
 
172
/**
 
173
 * Return the advance for a glyph.
 
174
 *
 
175
 * @param glyph  An FTGLglyph* object.
 
176
 * @return  The advance's X component.
 
177
 */
 
178
FTGL_EXPORT float ftglGetGlyphAdvance(FTGLglyph *glyph);
 
179
 
 
180
/**
 
181
 * Return the bounding box for a glyph.
 
182
 *
 
183
 * @param glyph  An FTGLglyph* object.
 
184
 * @param bounds  An array of 6 float values where the bounding box's lower
 
185
 *                left near and upper right far 3D coordinates will be stored.
 
186
 */
 
187
FTGL_EXPORT void ftglGetGlyphBBox(FTGLglyph *glyph, float bounds[6]);
 
188
 
 
189
/**
 
190
 * Query a glyph for errors.
 
191
 *
 
192
 * @param glyph  An FTGLglyph* object.
 
193
 * @return  The current error code.
 
194
 */
 
195
FTGL_EXPORT FT_Error ftglGetGlyphError(FTGLglyph* glyph);
 
196
 
 
197
FTGL_END_C_DECLS
 
198
 
 
199
#endif  //  __FTGlyph__
 
200