Watermark text for TGE
by Herru Cules D · 07/24/2008 (6:40 am) · 3 comments
This resource will give you 2d watermark text for TGE. This watermark will always on top of other gui child.
First open up engine/gui/core/guicanvas.cc on method void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */) exactly after
compile and rebuild the engine, now you can see the watermark on the below right edge of your game.
problem: if only I can set the font from C++ without finding guidefaultprofile (need help for this).
Thats it for now, hope it'll be usefull.
cheers.
herrucules.blogspot.com
First open up engine/gui/core/guicanvas.cc on method void GuiCanvas::renderFrame(bool preRenderOnly, bool bufferSwap /* = true */) exactly after
if (cursorON && mouseCursor && mShowCursor)
{
Point2I pos((S32)cursorPt.x, (S32)cursorPt.y);
Point2I spot = mouseCursor->getHotSpot();
pos -= spot;
mouseCursor->render(pos);
}Add this codebool WT = true; // enable/disable watermark
if(WT)
{
GuiControlProfile *mtProfile;
mtProfile = NULL;
// set the font to guidefaultprofile font
if( !mtProfile ) {
SimObject *obj = Sim::findObject( "GuiDefaultProfile" );
if( obj )
mtProfile = dynamic_cast<GuiControlProfile*>(obj);
else
return;
}
if(mtProfile)
{
const char* renderTip = "TGE Licenced to HD"; // any watermark text you like
ColorF mForegroundColor;
mForegroundColor.set( 1, 1, 1, 1 );
ColorI mFillColor;
//Vars used:
//Screensize (for position check)
//Offset to set position
//textBounds for text extent.
Point2I offset;
Point2I textBounds;
S32 textWidth = mtProfile->mFont->getStrWidth(renderTip);
//Create text bounds.
textBounds.x = textWidth+8;
textBounds.y = mtProfile->mFont->getHeight() + 4;
//Offset from below right edge
offset.y = size.y - textBounds.y - 10;
offset.x = size.x - textBounds.x - 10;
// Set rectangle for the box, and set the clip rectangle.
RectI rect(offset, textBounds);
dglSetClipRect(rect);
mFillColor.set(0,0,0,255);
dglDrawRectFill(rect, mFillColor);
mFillColor.set(255,255,255,255);
dglDrawRect( rect, mFillColor );
// Draw the text centered in the rectangle
dglSetBitmapModulation( mForegroundColor );
Point2I start;
start.set( ( textBounds.x - textWidth) / 2, ( textBounds.y - mtProfile->mFont->getHeight() ) / 2 );
dglDrawText( mtProfile->mFont, start + offset, renderTip, mtProfile->mFontColors );
dglClearBitmapModulation();
}
mtProfile = NULL;
}compile and rebuild the engine, now you can see the watermark on the below right edge of your game.
problem: if only I can set the font from C++ without finding guidefaultprofile (need help for this).
Thats it for now, hope it'll be usefull.
cheers.
herrucules.blogspot.com
About the author

Associate Orion Elenzil
Real Life Plus
eg, push a modeless Gui on top.