Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __ftgl__
00029 # warning This header is deprecated. Please use <FTGL/ftgl.h> from now.
00030 # include <FTGL/ftgl.h>
00031 #endif
00032
00033 #ifndef __FTBBox__
00034 #define __FTBBox__
00035
00036 #ifdef __cplusplus
00037
00038
00042 class FTGL_EXPORT FTBBox
00043 {
00044 public:
00048 FTBBox()
00049 : lower(0.0f, 0.0f, 0.0f),
00050 upper(0.0f, 0.0f, 0.0f)
00051 {}
00052
00056 FTBBox(float lx, float ly, float lz, float ux, float uy, float uz)
00057 : lower(lx, ly, lz),
00058 upper(ux, uy, uz)
00059 {}
00060
00064 FTBBox(FTPoint l, FTPoint u)
00065 : lower(l),
00066 upper(u)
00067 {}
00068
00075 FTBBox(FT_GlyphSlot glyph)
00076 : lower(0.0f, 0.0f, 0.0f),
00077 upper(0.0f, 0.0f, 0.0f)
00078 {
00079 FT_BBox bbox;
00080 FT_Outline_Get_CBox(&(glyph->outline), &bbox);
00081
00082 lower.X(static_cast<float>(bbox.xMin) / 64.0f);
00083 lower.Y(static_cast<float>(bbox.yMin) / 64.0f);
00084 lower.Z(0.0f);
00085 upper.X(static_cast<float>(bbox.xMax) / 64.0f);
00086 upper.Y(static_cast<float>(bbox.yMax) / 64.0f);
00087 upper.Z(0.0f);
00088 }
00089
00093 ~FTBBox()
00094 {}
00095
00100 void Invalidate()
00101 {
00102 lower = FTPoint(1.0f, 1.0f, 1.0f);
00103 upper = FTPoint(-1.0f, -1.0f, -1.0f);
00104 }
00105
00112 bool IsValid()
00113 {
00114 return lower.X() <= upper.X()
00115 && lower.Y() <= upper.Y()
00116 && lower.Z() <= upper.Z();
00117 }
00118
00124 FTBBox& operator += (const FTPoint vector)
00125 {
00126 lower += vector;
00127 upper += vector;
00128
00129 return *this;
00130 }
00131
00138 FTBBox& operator |= (const FTBBox& bbox)
00139 {
00140 if(bbox.lower.X() < lower.X()) lower.X(bbox.lower.X());
00141 if(bbox.lower.Y() < lower.Y()) lower.Y(bbox.lower.Y());
00142 if(bbox.lower.Z() < lower.Z()) lower.Z(bbox.lower.Z());
00143 if(bbox.upper.X() > upper.X()) upper.X(bbox.upper.X());
00144 if(bbox.upper.Y() > upper.Y()) upper.Y(bbox.upper.Y());
00145 if(bbox.upper.Z() > upper.Z()) upper.Z(bbox.upper.Z());
00146
00147 return *this;
00148 }
00149
00150 void SetDepth(float depth)
00151 {
00152 if(depth > 0)
00153 upper.Z(lower.Z() + depth);
00154 else
00155 lower.Z(upper.Z() + depth);
00156 }
00157
00158
00159 inline FTPoint const Upper() const
00160 {
00161 return upper;
00162 }
00163
00164
00165 inline FTPoint const Lower() const
00166 {
00167 return lower;
00168 }
00169
00170 private:
00174 FTPoint lower, upper;
00175 };
00176
00177 #endif //__cplusplus
00178
00179 #endif // __FTBBox__
00180