File: text_renderer_d3d9.cpp

package info (click to toggle)
glest 3.2.2-2
  • links: PTS, VCS
  • area: contrib
  • in suites: squeeze
  • size: 2,800 kB
  • ctags: 6,581
  • sloc: cpp: 32,575; sh: 8,341; makefile: 63
file content (40 lines) | stat: -rw-r--r-- 968 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "text_renderer_d3d9.h"

#include <d3d9.h>
#include <d3d9types.h>

#include "font_d3d9.h"
#include "d3d9_util.h"
#include "leak_dumper.h"

namespace Shared{ namespace Graphics{ namespace D3d9{

// ===============================================
//	class TextRenderer2DD3d9
// ===============================================

void TextRenderer2DD3d9::begin(const Font2D *font){
	this->font= font;
	this->color= Vec4f(1.0f);
}

void TextRenderer2DD3d9::render(const string &text, int x, int y, bool centered){
   	RECT rect;
	rect.bottom= y;
	rect.left= x;
	rect.top= y;
	rect.right= x;
	
	D3DCOLOR d3dColor= D3DCOLOR_ARGB(
		static_cast<int>(color.w*255),
		static_cast<int>(color.x*255),
		static_cast<int>(color.y*255),
		static_cast<int>(color.z*255));

	static_cast<const Font2DD3d9*>(font)->getD3dFont()->DrawText(text.c_str(), -1, &rect, DT_NOCLIP, d3dColor);
}

void TextRenderer2DD3d9::end(){
}

}}}//end namespace