-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFontclass.h
77 lines (59 loc) · 2.22 KB
/
Fontclass.h
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#pragma once
////////////////////////////////////////////////////////////////////////////////
// Filename: fontclass.h
////////////////////////////////////////////////////////////////////////////////
#ifndef _FONTCLASS_H_
#define _FONTCLASS_H_
//////////////
// INCLUDES //
//////////////
#include <d3d11.h>
#include <directxmath.h>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
using namespace DirectX;
///////////////////////
// MY CLASS INCLUDES //
///////////////////////
#include "textureclass.h"
////////////////////////////////////////////////////////////////////////////////
// Class name: FontClass
////////////////////////////////////////////////////////////////////////////////
class FontClass
{
private:
// The FontType structure is used to hold the indexing data read in from the font index file.The left and right are the TU texture coordinates.The size is the width of the character in pixels.
struct FontType
{
float left, right;
float top, bottom;
int size, height;
};
// The VertexType structure is for the actual vertex data used to build the square to render the text character on.The individual character will require two triangles to make a square.Those triangles will have position and texture data only.
struct VertexType
{
XMFLOAT3 position;
XMFLOAT2 texture;
};
public:
FontClass();
FontClass(const FontClass&);
~FontClass();
bool Initialize(ID3D11Device * device, ID3D11DeviceContext * deviceContext, char * fontFilename, char * textureFilename);
void Shutdown();
ID3D11ShaderResourceView* GetTexture();
// BuildVertexArray will handle building and returning a vertex array of triangles that will render the character sentence which was given as input to this function.This function will be called by the new TextClass to build vertex arrays of all the sentences it needs to render.
void BuildVertexArray(void*, char*, float, float);
private:
bool LoadFontData(char*);
void ReleaseFontData();
bool LoadTexture(ID3D11Device * device, ID3D11DeviceContext * deviceContext, char * fname);
void ReleaseTexture();
private:
FontType* m_Font;
TextureClass* m_Texture;
};
#endif