cleanup and style
This commit is contained in:
parent
dd27e32cfc
commit
501f34c27a
@ -63,37 +63,35 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
std::string name;
|
||||
std::string imgfile;
|
||||
int height;
|
||||
int ascender;
|
||||
int descender;
|
||||
int imgw, imgh;
|
||||
int padl, padr, padt, padb;
|
||||
int shortmap[256];
|
||||
std::vector<Character> chars;
|
||||
std::string Name;
|
||||
std::string ImageFile;
|
||||
int Height;
|
||||
int Ascender;
|
||||
int Descender;
|
||||
int ImgW, ImgH;
|
||||
int PadL, PadR, PadT, PadB;
|
||||
int ShortMap[256];
|
||||
std::vector<Character> Chars;
|
||||
|
||||
void *userPointer;
|
||||
long long userLong;
|
||||
|
||||
std::vector<unsigned char> rawimagefiledata;
|
||||
std::vector<unsigned char> RawImageFileData;
|
||||
|
||||
public:
|
||||
BitmapFont()
|
||||
{
|
||||
for (int i=0; i<256; ++i)
|
||||
shortmap[i] = 0;
|
||||
padl=padr=padt=padb=0;
|
||||
userPointer = NULL;
|
||||
userLong = 0;
|
||||
ShortMap[i] = 0;
|
||||
this->PadL=0;
|
||||
this->PadR=0;
|
||||
this->PadT=0;
|
||||
this->PadB=0;
|
||||
}
|
||||
Character GetChar(char c)
|
||||
{
|
||||
return chars[shortmap[(unsigned char)c]];
|
||||
return this->Chars[ShortMap[(unsigned char)c]];
|
||||
}
|
||||
std::vector<unsigned char> &GetRawImageData()
|
||||
{
|
||||
return rawimagefiledata;
|
||||
return this->RawImageFileData;
|
||||
}
|
||||
vtkm::Float32 GetTextWidth(const std::string &text)
|
||||
{
|
||||
@ -105,8 +103,8 @@ public:
|
||||
|
||||
const bool kerning = true;
|
||||
if (kerning && nextchar>0)
|
||||
width += vtkm::Float32(c.kern[int(nextchar)]) / vtkm::Float32(height);
|
||||
width += vtkm::Float32(c.adv) / vtkm::Float32(height);
|
||||
width += vtkm::Float32(c.kern[int(nextchar)]) / vtkm::Float32(this->Height);
|
||||
width += vtkm::Float32(c.adv) / vtkm::Float32(this->Height);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
@ -120,22 +118,22 @@ public:
|
||||
// By default, the origin for the font is at the
|
||||
// baseline. That's nice, but we'd rather it
|
||||
// be at the actual bottom, so create an offset.
|
||||
vtkm::Float32 yoff = -vtkm::Float32(descender) / vtkm::Float32(height);
|
||||
vtkm::Float32 yoff = -vtkm::Float32(this->Descender) / vtkm::Float32(this->Height);
|
||||
|
||||
tl = vtkm::Float32(c.x + padl) / vtkm::Float32(imgw);
|
||||
tr = vtkm::Float32(c.x + c.w - padr) / vtkm::Float32(imgw);
|
||||
tt = 1.f - vtkm::Float32(c.y + padt) / vtkm::Float32(imgh);
|
||||
tb = 1.f - vtkm::Float32(c.y + c.h - padb) / vtkm::Float32(imgh);
|
||||
tl = vtkm::Float32(c.x + this->PadL) / vtkm::Float32(this->ImgW);
|
||||
tr = vtkm::Float32(c.x + c.w - this->PadR) / vtkm::Float32(this->ImgW);
|
||||
tt = 1.f - vtkm::Float32(c.y + this->PadT) / vtkm::Float32(this->ImgH);
|
||||
tb = 1.f - vtkm::Float32(c.y + c.h - this->PadB) / vtkm::Float32(this->ImgH);
|
||||
|
||||
vl = x + vtkm::Float32(c.offx + padl) / vtkm::Float32(height);
|
||||
vr = x + vtkm::Float32(c.offx + c.w - padr) / vtkm::Float32(height);
|
||||
vt = yoff + y + vtkm::Float32(c.offy - padt) / vtkm::Float32(height);
|
||||
vb = yoff + y + vtkm::Float32(c.offy - c.h + padb) / vtkm::Float32(height);
|
||||
vl = x + vtkm::Float32(c.offx + this->PadL) / vtkm::Float32(this->Height);
|
||||
vr = x + vtkm::Float32(c.offx + c.w - this->PadR) / vtkm::Float32(this->Height);
|
||||
vt = yoff + y + vtkm::Float32(c.offy - this->PadT) / vtkm::Float32(this->Height);
|
||||
vb = yoff + y + vtkm::Float32(c.offy - c.h + this->PadB) / vtkm::Float32(this->Height);
|
||||
|
||||
const bool kerning = true;
|
||||
if (kerning && nextchar>0)
|
||||
x += vtkm::Float32(c.kern[int(nextchar)]) / vtkm::Float32(height);
|
||||
x += vtkm::Float32(c.adv) / vtkm::Float32(height);
|
||||
x += vtkm::Float32(c.kern[int(nextchar)]) / vtkm::Float32(this->Height);
|
||||
x += vtkm::Float32(c.adv) / vtkm::Float32(this->Height);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9553,135 +9553,135 @@ public:
|
||||
};
|
||||
|
||||
BitmapFont font;
|
||||
font.name = "Liberation 2 Sans";
|
||||
font.height = 129;
|
||||
font.ascender = 102;
|
||||
font.descender = -24;
|
||||
font.imgw = 1024;
|
||||
font.imgh = 1024;
|
||||
font.padl = 16;
|
||||
font.padr = 16;
|
||||
font.padt = 14;
|
||||
font.padb = 14;
|
||||
font.rawimagefiledata.insert(
|
||||
font.rawimagefiledata.begin(),
|
||||
font.Name = "Liberation 2 Sans";
|
||||
font.Height = 129;
|
||||
font.Ascender = 102;
|
||||
font.Descender = -24;
|
||||
font.ImgW = 1024;
|
||||
font.ImgH = 1024;
|
||||
font.PadL = 16;
|
||||
font.PadR = 16;
|
||||
font.PadT = 14;
|
||||
font.PadB = 14;
|
||||
font.RawImageFileData.insert(
|
||||
font.RawImageFileData.begin(),
|
||||
Liberation2Sans_rawimage,
|
||||
Liberation2Sans_rawimage + Liberation2Sans_imagelength);
|
||||
for (int i=0; i<95; i++)
|
||||
{
|
||||
font.chars.push_back(BitmapFont::Character(Liberation2Sans_charids[i],
|
||||
font.Chars.push_back(BitmapFont::Character(Liberation2Sans_charids[i],
|
||||
Liberation2Sans_charmetrics[i]));
|
||||
font.shortmap[Liberation2Sans_charmetrics[i][0]] = i;
|
||||
font.ShortMap[Liberation2Sans_charmetrics[i][0]] = i;
|
||||
}
|
||||
|
||||
// Character
|
||||
font.chars[0].kern[65] = -6;
|
||||
font.chars[0].kern[84] = -2;
|
||||
font.chars[0].kern[89] = -2;
|
||||
font.Chars[0].kern[65] = -6;
|
||||
font.Chars[0].kern[84] = -2;
|
||||
font.Chars[0].kern[89] = -2;
|
||||
// Character A
|
||||
font.chars[33].kern[32] = -6;
|
||||
font.chars[33].kern[84] = -8;
|
||||
font.chars[33].kern[86] = -8;
|
||||
font.chars[33].kern[87] = -4;
|
||||
font.chars[33].kern[89] = -8;
|
||||
font.chars[33].kern[118] = -2;
|
||||
font.chars[33].kern[119] = -2;
|
||||
font.chars[33].kern[121] = -2;
|
||||
font.Chars[33].kern[32] = -6;
|
||||
font.Chars[33].kern[84] = -8;
|
||||
font.Chars[33].kern[86] = -8;
|
||||
font.Chars[33].kern[87] = -4;
|
||||
font.Chars[33].kern[89] = -8;
|
||||
font.Chars[33].kern[118] = -2;
|
||||
font.Chars[33].kern[119] = -2;
|
||||
font.Chars[33].kern[121] = -2;
|
||||
// Character F
|
||||
font.chars[38].kern[44] = -12;
|
||||
font.chars[38].kern[46] = -12;
|
||||
font.chars[38].kern[65] = -6;
|
||||
font.Chars[38].kern[44] = -12;
|
||||
font.Chars[38].kern[46] = -12;
|
||||
font.Chars[38].kern[65] = -6;
|
||||
// Character L
|
||||
font.chars[44].kern[32] = -4;
|
||||
font.chars[44].kern[84] = -8;
|
||||
font.chars[44].kern[86] = -8;
|
||||
font.chars[44].kern[87] = -8;
|
||||
font.chars[44].kern[89] = -8;
|
||||
font.chars[44].kern[121] = -4;
|
||||
font.Chars[44].kern[32] = -4;
|
||||
font.Chars[44].kern[84] = -8;
|
||||
font.Chars[44].kern[86] = -8;
|
||||
font.Chars[44].kern[87] = -8;
|
||||
font.Chars[44].kern[89] = -8;
|
||||
font.Chars[44].kern[121] = -4;
|
||||
// Character P
|
||||
font.chars[48].kern[32] = -2;
|
||||
font.chars[48].kern[44] = -14;
|
||||
font.chars[48].kern[46] = -14;
|
||||
font.chars[48].kern[65] = -8;
|
||||
font.Chars[48].kern[32] = -2;
|
||||
font.Chars[48].kern[44] = -14;
|
||||
font.Chars[48].kern[46] = -14;
|
||||
font.Chars[48].kern[65] = -8;
|
||||
// Character R
|
||||
font.chars[50].kern[84] = -2;
|
||||
font.chars[50].kern[86] = -2;
|
||||
font.chars[50].kern[87] = -2;
|
||||
font.chars[50].kern[89] = -2;
|
||||
font.Chars[50].kern[84] = -2;
|
||||
font.Chars[50].kern[86] = -2;
|
||||
font.Chars[50].kern[87] = -2;
|
||||
font.Chars[50].kern[89] = -2;
|
||||
// Character T
|
||||
font.chars[52].kern[32] = -2;
|
||||
font.chars[52].kern[44] = -12;
|
||||
font.chars[52].kern[45] = -6;
|
||||
font.chars[52].kern[46] = -12;
|
||||
font.chars[52].kern[58] = -12;
|
||||
font.chars[52].kern[59] = -12;
|
||||
font.chars[52].kern[65] = -8;
|
||||
font.chars[52].kern[79] = -2;
|
||||
font.chars[52].kern[97] = -12;
|
||||
font.chars[52].kern[99] = -12;
|
||||
font.chars[52].kern[101] = -12;
|
||||
font.chars[52].kern[105] = -4;
|
||||
font.chars[52].kern[111] = -12;
|
||||
font.chars[52].kern[114] = -4;
|
||||
font.chars[52].kern[115] = -12;
|
||||
font.chars[52].kern[117] = -4;
|
||||
font.chars[52].kern[119] = -6;
|
||||
font.chars[52].kern[121] = -6;
|
||||
font.Chars[52].kern[32] = -2;
|
||||
font.Chars[52].kern[44] = -12;
|
||||
font.Chars[52].kern[45] = -6;
|
||||
font.Chars[52].kern[46] = -12;
|
||||
font.Chars[52].kern[58] = -12;
|
||||
font.Chars[52].kern[59] = -12;
|
||||
font.Chars[52].kern[65] = -8;
|
||||
font.Chars[52].kern[79] = -2;
|
||||
font.Chars[52].kern[97] = -12;
|
||||
font.Chars[52].kern[99] = -12;
|
||||
font.Chars[52].kern[101] = -12;
|
||||
font.Chars[52].kern[105] = -4;
|
||||
font.Chars[52].kern[111] = -12;
|
||||
font.Chars[52].kern[114] = -4;
|
||||
font.Chars[52].kern[115] = -12;
|
||||
font.Chars[52].kern[117] = -4;
|
||||
font.Chars[52].kern[119] = -6;
|
||||
font.Chars[52].kern[121] = -6;
|
||||
// Character V
|
||||
font.chars[54].kern[44] = -10;
|
||||
font.chars[54].kern[45] = -6;
|
||||
font.chars[54].kern[46] = -10;
|
||||
font.chars[54].kern[58] = -4;
|
||||
font.chars[54].kern[59] = -4;
|
||||
font.chars[54].kern[65] = -8;
|
||||
font.chars[54].kern[97] = -8;
|
||||
font.chars[54].kern[101] = -6;
|
||||
font.chars[54].kern[105] = -2;
|
||||
font.chars[54].kern[111] = -6;
|
||||
font.chars[54].kern[114] = -4;
|
||||
font.chars[54].kern[117] = -4;
|
||||
font.chars[54].kern[121] = -4;
|
||||
font.Chars[54].kern[44] = -10;
|
||||
font.Chars[54].kern[45] = -6;
|
||||
font.Chars[54].kern[46] = -10;
|
||||
font.Chars[54].kern[58] = -4;
|
||||
font.Chars[54].kern[59] = -4;
|
||||
font.Chars[54].kern[65] = -8;
|
||||
font.Chars[54].kern[97] = -8;
|
||||
font.Chars[54].kern[101] = -6;
|
||||
font.Chars[54].kern[105] = -2;
|
||||
font.Chars[54].kern[111] = -6;
|
||||
font.Chars[54].kern[114] = -4;
|
||||
font.Chars[54].kern[117] = -4;
|
||||
font.Chars[54].kern[121] = -4;
|
||||
// Character W
|
||||
font.chars[55].kern[44] = -6;
|
||||
font.chars[55].kern[45] = -2;
|
||||
font.chars[55].kern[46] = -6;
|
||||
font.chars[55].kern[58] = -2;
|
||||
font.chars[55].kern[59] = -2;
|
||||
font.chars[55].kern[65] = -4;
|
||||
font.chars[55].kern[97] = -4;
|
||||
font.chars[55].kern[101] = -2;
|
||||
font.chars[55].kern[111] = -2;
|
||||
font.chars[55].kern[114] = -2;
|
||||
font.chars[55].kern[117] = -2;
|
||||
font.chars[55].kern[121] = -1;
|
||||
font.Chars[55].kern[44] = -6;
|
||||
font.Chars[55].kern[45] = -2;
|
||||
font.Chars[55].kern[46] = -6;
|
||||
font.Chars[55].kern[58] = -2;
|
||||
font.Chars[55].kern[59] = -2;
|
||||
font.Chars[55].kern[65] = -4;
|
||||
font.Chars[55].kern[97] = -4;
|
||||
font.Chars[55].kern[101] = -2;
|
||||
font.Chars[55].kern[111] = -2;
|
||||
font.Chars[55].kern[114] = -2;
|
||||
font.Chars[55].kern[117] = -2;
|
||||
font.Chars[55].kern[121] = -1;
|
||||
// Character Y
|
||||
font.chars[57].kern[32] = -2;
|
||||
font.chars[57].kern[44] = -14;
|
||||
font.chars[57].kern[45] = -10;
|
||||
font.chars[57].kern[46] = -14;
|
||||
font.chars[57].kern[58] = -6;
|
||||
font.chars[57].kern[59] = -7;
|
||||
font.chars[57].kern[65] = -8;
|
||||
font.chars[57].kern[97] = -8;
|
||||
font.chars[57].kern[101] = -10;
|
||||
font.chars[57].kern[105] = -4;
|
||||
font.chars[57].kern[111] = -10;
|
||||
font.chars[57].kern[112] = -8;
|
||||
font.chars[57].kern[113] = -10;
|
||||
font.chars[57].kern[117] = -6;
|
||||
font.chars[57].kern[118] = -6;
|
||||
font.Chars[57].kern[32] = -2;
|
||||
font.Chars[57].kern[44] = -14;
|
||||
font.Chars[57].kern[45] = -10;
|
||||
font.Chars[57].kern[46] = -14;
|
||||
font.Chars[57].kern[58] = -6;
|
||||
font.Chars[57].kern[59] = -7;
|
||||
font.Chars[57].kern[65] = -8;
|
||||
font.Chars[57].kern[97] = -8;
|
||||
font.Chars[57].kern[101] = -10;
|
||||
font.Chars[57].kern[105] = -4;
|
||||
font.Chars[57].kern[111] = -10;
|
||||
font.Chars[57].kern[112] = -8;
|
||||
font.Chars[57].kern[113] = -10;
|
||||
font.Chars[57].kern[117] = -6;
|
||||
font.Chars[57].kern[118] = -6;
|
||||
// Character r
|
||||
font.chars[82].kern[44] = -6;
|
||||
font.chars[82].kern[46] = -6;
|
||||
font.Chars[82].kern[44] = -6;
|
||||
font.Chars[82].kern[46] = -6;
|
||||
// Character v
|
||||
font.chars[86].kern[44] = -8;
|
||||
font.chars[86].kern[46] = -8;
|
||||
font.Chars[86].kern[44] = -8;
|
||||
font.Chars[86].kern[46] = -8;
|
||||
// Character w
|
||||
font.chars[87].kern[44] = -6;
|
||||
font.chars[87].kern[46] = -6;
|
||||
font.Chars[87].kern[44] = -6;
|
||||
font.Chars[87].kern[46] = -6;
|
||||
// Character y
|
||||
font.chars[89].kern[44] = -8;
|
||||
font.chars[89].kern[46] = -8;
|
||||
font.Chars[89].kern[44] = -8;
|
||||
font.Chars[89].kern[46] = -8;
|
||||
return font;
|
||||
}
|
||||
};
|
||||
|
@ -226,17 +226,17 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
BitmapFont font;
|
||||
TextureGL fontTexture;
|
||||
BitmapFont Font;
|
||||
TextureGL FontTexture;
|
||||
|
||||
void RenderText(vtkm::Float32 scale,
|
||||
vtkm::Float32 anchorx, vtkm::Float32 anchory,
|
||||
std::string text)
|
||||
{
|
||||
if (fontTexture.id == 0)
|
||||
if (this->FontTexture.ID == 0)
|
||||
{
|
||||
font = BitmapFontFactory::CreateLiberation2Sans();
|
||||
std::vector<unsigned char> &rawpngdata = font.GetRawImageData();
|
||||
Font = BitmapFontFactory::CreateLiberation2Sans();
|
||||
std::vector<unsigned char> &rawpngdata = this->Font.GetRawImageData();
|
||||
|
||||
std::vector<unsigned char> rgba;
|
||||
unsigned long width, height;
|
||||
@ -247,11 +247,11 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
fontTexture.CreateAlphaFromRGBA(int(width),int(height),rgba);
|
||||
this->FontTexture.CreateAlphaFromRGBA(int(width),int(height),rgba);
|
||||
}
|
||||
|
||||
|
||||
fontTexture.Enable();
|
||||
this->FontTexture.Enable();
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@ -262,7 +262,7 @@ private:
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
vtkm::Float32 textwidth = font.GetTextWidth(text);
|
||||
vtkm::Float32 textwidth = this->Font.GetTextWidth(text);
|
||||
|
||||
vtkm::Float32 fx = -(.5f + .5f*anchorx) * textwidth;
|
||||
vtkm::Float32 fy = -(.5f + .5f*anchory);
|
||||
@ -274,7 +274,7 @@ private:
|
||||
|
||||
vtkm::Float32 vl,vr,vt,vb;
|
||||
vtkm::Float32 tl,tr,tt,tb;
|
||||
font.GetCharPolygon(c, fx, fy,
|
||||
this->Font.GetCharPolygon(c, fx, fy,
|
||||
vl, vr, vt, vb,
|
||||
tl, tr, tt, tb, nextchar);
|
||||
|
||||
@ -293,7 +293,7 @@ private:
|
||||
|
||||
glEnd();
|
||||
|
||||
fontTexture.Disable();
|
||||
this->FontTexture.Disable();
|
||||
|
||||
//glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
@ -44,38 +44,38 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
std::string text;
|
||||
Color color;
|
||||
vtkm::Float32 scale;
|
||||
vtkm::Float32 anchorx, anchory;
|
||||
std::string Text;
|
||||
Color TextColor;
|
||||
vtkm::Float32 Scale;
|
||||
vtkm::Float32 AnchorX, AnchorY;
|
||||
|
||||
public:
|
||||
TextAnnotation(const std::string &txt, Color c, vtkm::Float32 s)
|
||||
: text(txt), color(c), scale(s)
|
||||
: Text(txt), TextColor(c), Scale(s)
|
||||
{
|
||||
// default anchor: bottom-left
|
||||
anchorx = -1;
|
||||
anchory = -1;
|
||||
AnchorX = -1;
|
||||
AnchorY = -1;
|
||||
}
|
||||
virtual ~TextAnnotation()
|
||||
{
|
||||
}
|
||||
void SetText(const std::string &txt)
|
||||
{
|
||||
text = txt;
|
||||
Text = txt;
|
||||
}
|
||||
void SetRawAnchor(vtkm::Float32 h, vtkm::Float32 v)
|
||||
{
|
||||
anchorx = h;
|
||||
anchory = v;
|
||||
AnchorX = h;
|
||||
AnchorY = v;
|
||||
}
|
||||
void SetAlignment(HorizontalAlignment h, VerticalAlignment v)
|
||||
{
|
||||
switch (h)
|
||||
{
|
||||
case Left: anchorx = -1.0f; break;
|
||||
case HCenter: anchorx = 0.0f; break;
|
||||
case Right: anchorx = +1.0f; break;
|
||||
case Left: AnchorX = -1.0f; break;
|
||||
case HCenter: AnchorX = 0.0f; break;
|
||||
case Right: AnchorX = +1.0f; break;
|
||||
}
|
||||
|
||||
// For vertical alignment, "center" is generally the center
|
||||
@ -89,14 +89,14 @@ public:
|
||||
// the bottom of the window.
|
||||
switch (v)
|
||||
{
|
||||
case Bottom: anchory = -1.0f; break;
|
||||
case VCenter: anchory = -0.06f; break;
|
||||
case Top: anchory = +1.0f; break;
|
||||
case Bottom: AnchorY = -1.0f; break;
|
||||
case VCenter: AnchorY = -0.06f; break;
|
||||
case Top: AnchorY = +1.0f; break;
|
||||
}
|
||||
}
|
||||
void SetScale(vtkm::Float32 s)
|
||||
{
|
||||
scale = s;
|
||||
Scale = s;
|
||||
}
|
||||
virtual void Render(View &view,
|
||||
WorldAnnotator &worldAnnotator,
|
||||
@ -106,21 +106,21 @@ public:
|
||||
class ScreenTextAnnotation : public TextAnnotation
|
||||
{
|
||||
protected:
|
||||
vtkm::Float32 x,y;
|
||||
vtkm::Float32 angle;
|
||||
vtkm::Float32 XPos,YPos;
|
||||
vtkm::Float32 Angle;
|
||||
public:
|
||||
ScreenTextAnnotation(const std::string &txt, Color c, vtkm::Float32 s,
|
||||
vtkm::Float32 ox, vtkm::Float32 oy, vtkm::Float32 angleDeg = 0.)
|
||||
: TextAnnotation(txt,c,s)
|
||||
{
|
||||
x = ox;
|
||||
y = oy;
|
||||
angle = angleDeg;
|
||||
XPos = ox;
|
||||
YPos = oy;
|
||||
Angle = angleDeg;
|
||||
}
|
||||
void SetPosition(vtkm::Float32 ox, vtkm::Float32 oy)
|
||||
{
|
||||
x = ox;
|
||||
y = oy;
|
||||
XPos = ox;
|
||||
YPos = oy;
|
||||
}
|
||||
virtual void Render(View &view,
|
||||
WorldAnnotator &,
|
||||
@ -129,36 +129,36 @@ public:
|
||||
vtkm::Float32 WindowAspect = vtkm::Float32(view.Width) /
|
||||
vtkm::Float32(view.Height);
|
||||
|
||||
renderSurface.AddText(x,y,
|
||||
scale,
|
||||
angle,
|
||||
renderSurface.AddText(XPos,YPos,
|
||||
Scale,
|
||||
Angle,
|
||||
WindowAspect,
|
||||
anchorx, anchory,
|
||||
color, text);
|
||||
AnchorX, AnchorY,
|
||||
TextColor, Text);
|
||||
}
|
||||
};
|
||||
|
||||
class BillboardTextAnnotation : public TextAnnotation
|
||||
{
|
||||
protected:
|
||||
vtkm::Float32 x,y,z;
|
||||
vtkm::Float32 angle;
|
||||
vtkm::Float32 XPos,YPos,ZPos;
|
||||
vtkm::Float32 Angle;
|
||||
public:
|
||||
BillboardTextAnnotation(const std::string &txt, Color c, vtkm::Float32 s,
|
||||
vtkm::Float32 ox, vtkm::Float32 oy, vtkm::Float32 oz,
|
||||
vtkm::Float32 angleDeg = 0.)
|
||||
: TextAnnotation(txt,c,s)
|
||||
{
|
||||
x = ox;
|
||||
y = oy;
|
||||
z = oz;
|
||||
angle = angleDeg;
|
||||
XPos = ox;
|
||||
YPos = oy;
|
||||
ZPos = oz;
|
||||
Angle = angleDeg;
|
||||
}
|
||||
void SetPosition(vtkm::Float32 ox, vtkm::Float32 oy, vtkm::Float32 oz)
|
||||
{
|
||||
x = ox;
|
||||
y = oy;
|
||||
z = oz;
|
||||
XPos = ox;
|
||||
YPos = oy;
|
||||
ZPos = oz;
|
||||
}
|
||||
|
||||
virtual void Render(View &view,
|
||||
@ -169,7 +169,7 @@ public:
|
||||
V = view.CreateViewMatrix();
|
||||
P = view.CreateProjectionMatrix();
|
||||
|
||||
vtkm::Vec<vtkm::Float32,4> p4w(x,y,z,1);
|
||||
vtkm::Vec<vtkm::Float32,4> p4w(XPos,YPos,ZPos,1);
|
||||
vtkm::Vec<vtkm::Float32,4> p4s =
|
||||
vtkm::MatrixMultiply(vtkm::MatrixMultiply(P,V), p4w);
|
||||
|
||||
@ -201,7 +201,7 @@ public:
|
||||
}
|
||||
|
||||
vtkm::Matrix<vtkm::Float32, 4, 4> R;
|
||||
R = MatrixHelpers::RotateZMatrix(angle * 3.14159265f / 180.f);
|
||||
R = MatrixHelpers::RotateZMatrix(Angle * 3.14159265f / 180.f);
|
||||
|
||||
vtkm::Vec<vtkm::Float32,4> origin4(0,0,0,1);
|
||||
vtkm::Vec<vtkm::Float32,4> right4(1,0,0,0);
|
||||
@ -235,9 +235,9 @@ public:
|
||||
worldAnnotator.AddText(px,py,pz,
|
||||
rx,ry,rz,
|
||||
ux,uy,uz,
|
||||
scale,
|
||||
anchorx, anchory,
|
||||
color, text);
|
||||
Scale,
|
||||
AnchorX, AnchorY,
|
||||
TextColor, Text);
|
||||
|
||||
renderSurface.SetViewToWorldSpace(view,true);
|
||||
}
|
||||
|
@ -32,32 +32,32 @@ namespace rendering {
|
||||
|
||||
class TextureGL
|
||||
{
|
||||
public:
|
||||
GLuint id;
|
||||
int dim;
|
||||
bool mipmap;
|
||||
bool linear2D;
|
||||
bool linearMip;
|
||||
public:
|
||||
public:
|
||||
GLuint ID;
|
||||
int Dimension;
|
||||
bool MIPMap;
|
||||
bool Linear2D;
|
||||
bool LinearMIP;
|
||||
public:
|
||||
TextureGL()
|
||||
{
|
||||
id = 0;
|
||||
dim = 0;
|
||||
mipmap = false;
|
||||
linear2D = true;
|
||||
linearMip = true;
|
||||
this->ID = 0;
|
||||
this->Dimension = 0;
|
||||
this->MIPMap = false;
|
||||
this->Linear2D = true;
|
||||
this->LinearMIP = true;
|
||||
}
|
||||
void Enable()
|
||||
{
|
||||
if (id == 0)
|
||||
if (this->ID == 0)
|
||||
return;
|
||||
|
||||
if (dim == 1)
|
||||
if (this->Dimension == 1)
|
||||
{
|
||||
// no mipmapping for 1D (at the moment)
|
||||
glBindTexture(GL_TEXTURE_1D, id);
|
||||
// no this->MIPMapping for 1D (at the moment)
|
||||
glBindTexture(GL_TEXTURE_1D, this->ID);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
if (linear2D)
|
||||
if (this->Linear2D)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
@ -69,17 +69,17 @@ class TextureGL
|
||||
}
|
||||
glEnable(GL_TEXTURE_1D);
|
||||
}
|
||||
else if (dim == 2)
|
||||
else if (this->Dimension == 2)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glBindTexture(GL_TEXTURE_2D, this->ID);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||
if (linear2D)
|
||||
if (this->Linear2D)
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
if (!mipmap)
|
||||
if (!this->MIPMap)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
else if (linearMip)
|
||||
else if (this->LinearMIP)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||
else
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
|
||||
@ -87,9 +87,9 @@ class TextureGL
|
||||
else
|
||||
{
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
if (!mipmap)
|
||||
if (!this->MIPMap)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
else if (linearMip)
|
||||
else if (this->LinearMIP)
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_LINEAR);
|
||||
else
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
|
||||
@ -99,32 +99,32 @@ class TextureGL
|
||||
}
|
||||
void Disable()
|
||||
{
|
||||
if (dim == 1)
|
||||
if (this->Dimension == 1)
|
||||
glDisable(GL_TEXTURE_1D);
|
||||
else if (dim == 2)
|
||||
else if (this->Dimension == 2)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
void CreateAlphaFromRGBA(int w, int h, std::vector<unsigned char> &rgba)
|
||||
{
|
||||
dim = 2;
|
||||
this->Dimension = 2;
|
||||
std::vector<unsigned char> alpha(rgba.size()/4);
|
||||
for (unsigned int i=0; i<alpha.size(); i++)
|
||||
{
|
||||
alpha[i] = rgba[i*4+3];
|
||||
}
|
||||
|
||||
if (id == 0)
|
||||
if (this->ID == 0)
|
||||
{
|
||||
glGenTextures(1, &id);
|
||||
glGenTextures(1, &this->ID);
|
||||
}
|
||||
|
||||
if (dim == 1)
|
||||
if (this->Dimension == 1)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_1D, id);
|
||||
glBindTexture(GL_TEXTURE_1D, this->ID);
|
||||
}
|
||||
else if (dim == 2)
|
||||
else if (this->Dimension == 2)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
glBindTexture(GL_TEXTURE_2D, this->ID);
|
||||
//#define HW_MIPMAPS
|
||||
#ifdef HW_MIPMAPS
|
||||
mpimap = true;
|
||||
|
@ -93,17 +93,17 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
BitmapFont font;
|
||||
TextureGL fontTexture;
|
||||
BitmapFont Font;
|
||||
TextureGL FontTexture;
|
||||
|
||||
void RenderText(vtkm::Float32 scale,
|
||||
vtkm::Float32 anchorx, vtkm::Float32 anchory,
|
||||
std::string text)
|
||||
{
|
||||
if (fontTexture.id == 0)
|
||||
if (this->FontTexture.ID == 0)
|
||||
{
|
||||
font = BitmapFontFactory::CreateLiberation2Sans();
|
||||
std::vector<unsigned char> &rawpngdata = font.GetRawImageData();
|
||||
Font = BitmapFontFactory::CreateLiberation2Sans();
|
||||
std::vector<unsigned char> &rawpngdata = this->Font.GetRawImageData();
|
||||
|
||||
std::vector<unsigned char> rgba;
|
||||
unsigned long width, height;
|
||||
@ -114,11 +114,11 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
fontTexture.CreateAlphaFromRGBA(int(width),int(height),rgba);
|
||||
this->FontTexture.CreateAlphaFromRGBA(int(width),int(height),rgba);
|
||||
}
|
||||
|
||||
|
||||
fontTexture.Enable();
|
||||
this->FontTexture.Enable();
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
@ -129,7 +129,7 @@ private:
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
vtkm::Float32 textwidth = font.GetTextWidth(text);
|
||||
vtkm::Float32 textwidth = this->Font.GetTextWidth(text);
|
||||
|
||||
vtkm::Float32 fx = -(.5f + .5f*anchorx) * textwidth;
|
||||
vtkm::Float32 fy = -(.5f + .5f*anchory);
|
||||
@ -141,7 +141,7 @@ private:
|
||||
|
||||
vtkm::Float32 vl,vr,vt,vb;
|
||||
vtkm::Float32 tl,tr,tt,tb;
|
||||
font.GetCharPolygon(c, fx, fy,
|
||||
this->Font.GetCharPolygon(c, fx, fy,
|
||||
vl, vr, vt, vb,
|
||||
tl, tr, tt, tb, nextchar);
|
||||
|
||||
@ -160,7 +160,7 @@ private:
|
||||
|
||||
glEnd();
|
||||
|
||||
fontTexture.Disable();
|
||||
this->FontTexture.Disable();
|
||||
|
||||
//glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, 0);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user