1 /* 2 * FTGL - OpenGL font library 3 * 4 * Copyright (c) 2008 Sam Hocevar <sam@hocevar.net> 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining 7 * a copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sublicense, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be 15 * included in all copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 21 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 22 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 23 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 */ 25 26 #ifndef __ftgl__ 27 # warning Please use <FTGL/ftgl.h> instead of <FTBuffer.h>. 28 # include <FTGL/ftgl.h> 29 #endif 30 31 #ifndef __FTBuffer__ 32 #define __FTBuffer__ 33 34 #ifdef __cplusplus 35 36 /** 37 * FTBuffer is a helper class for pixel buffers. 38 * 39 * It provides the interface between FTBufferFont and FTBufferGlyph to 40 * optimise rendering operations. 41 * 42 * @see FTBufferGlyph 43 * @see FTBufferFont 44 */ 45 class FTGL_EXPORT FTBuffer 46 { 47 public: 48 /** 49 * Default constructor. 50 */ 51 FTBuffer(); 52 53 /** 54 * Destructor 55 */ 56 ~FTBuffer(); 57 58 /** 59 * Get the pen's position in the buffer. 60 * 61 * @return The pen's position as an FTPoint object. 62 */ Pos()63 inline FTPoint Pos() const 64 { 65 return pos; 66 } 67 68 /** 69 * Set the pen's position in the buffer. 70 * 71 * @param arg An FTPoint object with the desired pen's position. 72 */ Pos(FTPoint arg)73 inline void Pos(FTPoint arg) 74 { 75 pos = arg; 76 } 77 78 /** 79 * Set the buffer's size. 80 * 81 * @param w The buffer's desired width, in pixels. 82 * @param h The buffer's desired height, in pixels. 83 */ 84 void Size(int w, int h); 85 86 /** 87 * Get the buffer's width. 88 * 89 * @return The buffer's width, in pixels. 90 */ Width()91 inline int Width() const { return width; } 92 93 /** 94 * Get the buffer's height. 95 * 96 * @return The buffer's height, in pixels. 97 */ Height()98 inline int Height() const { return height; } 99 100 /** 101 * Get the buffer's direct pixel buffer. 102 * 103 * @return A read-write pointer to the buffer's pixels. 104 */ Pixels()105 inline unsigned char *Pixels() const { return pixels; } 106 107 private: 108 /** 109 * Buffer's width and height. 110 */ 111 int width, height; 112 113 /** 114 * Buffer's pixel buffer. 115 */ 116 unsigned char *pixels; 117 118 /** 119 * Buffer's internal pen position. 120 */ 121 FTPoint pos; 122 }; 123 124 #endif //__cplusplus 125 126 #endif // __FTBuffer__ 127 128