File: font_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 (38 lines) | stat: -rw-r--r-- 979 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
#include "font_d3d9.h"

#include <stdexcept>

#include <d3d9.h> 

#include "graphics_interface.h"
#include "context_d3d9.h"
#include "leak_dumper.h"

using namespace std;

namespace Shared{ namespace Graphics{ namespace D3d9{

// ===============================================
//	class Font2DD3d9
// ===============================================

void Font2DD3d9::init(){
	GraphicsInterface &gi= GraphicsInterface::getInstance();
	IDirect3DDevice9 *d3dDevice= static_cast<ContextD3d9*>(gi.getCurrentContext())->getD3dDevice();

	HFONT hFont=CreateFont(size, 0, 0, 0, width, 0, FALSE, FALSE, ANSI_CHARSET,
		OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH, type.c_str());

	HRESULT result= D3DXCreateFont(d3dDevice, hFont, &d3dFont);
	if(result!=D3D_OK){
		throw runtime_error("FontD3d9::init() -> Can't create D3D font");
	}
	DeleteObject(hFont);
}

void Font2DD3d9::end(){
	d3dFont->Release();
}


}}}//end namespace