Ejemplo n.º 1
0
void UIContext::DrawText(const char *str, float x, float y, uint32_t color, int align) {
	if (!textDrawer_ || (align & FLAG_DYNAMIC_ASCII)) {
		float sizeFactor = (float)fontStyle_->sizePts / 24.0f;
		Draw()->SetFontScale(fontScaleX_ * sizeFactor, fontScaleY_ * sizeFactor);
		Draw()->DrawText(fontStyle_->atlasFont, str, x, y, color, align);
	} else {
		textDrawer_->SetFontScale(fontScaleX_, fontScaleY_);
		textDrawer_->DrawString(*Draw(), str, x, y, color, align);
		RebindTexture();
	}
}
void FPSSurface::Handle(Core::ProcessEventArg arg) {
    frames += 1;
    unsigned int elapsed = timer.GetElapsedTime().AsInt();
    if (elapsed > interval) {
        double d = (double) frames * 1000000 / elapsed;


	char timestring[255];
	sprintf(timestring, "FPS:%.1f",d);
	std::string time = Convert::ToString(timestring);

	if (fpsString != time) {
	    text.DrawText(time, this);
	    RebindTexture();
	}
        frames = 0;
        timer.Reset();
    }
}