outlinefont.cpp

来自「这是整套横扫千军3D版游戏的源码」· C++ 代码 · 共 44 行

CPP
44
字号
#include "StdAfx.h"
// OutlineFont.cpp: implementation of the COutlineFont class.
//
//////////////////////////////////////////////////////////////////////

#include "OutlineFont.h"
#include <string>
#include "Rendering/glFont.h"

/******************************************************************************/


COutlineFont outlineFont;


COutlineFont::COutlineFont() : enabled(true)
{
}


COutlineFont::~COutlineFont()
{
}


void COutlineFont::print(float xps, float yps,
                         const float color[4], const char* text) const
{
	const float luminance = (color[0] * 0.299f) +
	                        (color[1] * 0.587f) +
	                        (color[2] * 0.114f);
	                        
	const float darkOutline[4]  = { 0.25f, 0.25f, 0.25f, 0.8f };
	const float lightOutline[4] = { 0.85f, 0.85f, 0.85f, 0.8f };

	const float* outlineColor;
	if (luminance > 0.25f) {
		outlineColor = darkOutline;
	} else {
		outlineColor = lightOutline;
	}
	font->glPrintOutlined(text, xps, yps, color, outlineColor);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?