-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOGLJText.h
More file actions
75 lines (72 loc) · 2.39 KB
/
Copy pathOGLJText.h
File metadata and controls
75 lines (72 loc) · 2.39 KB
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
/*! @file
@brief COGLJTextクラスヘッダ
@author Nobuki HIRAMINE
@date 2009/09/21 : 新規作成
@note なし*/
#pragma once
#include <gl\gl.h>
/*! @brief OpenGLで日本語テキストを描画するためのクラス
@date 2009/09/21 : 新規作成
@note なし*/
class COGLJText
{
public:
//! 基点位置
enum EORIGINALPOS
{
OP_LEFTTOP = 0, //!< 左上
OP_RIGHTTOP, //!< 右上
OP_LEFTBOTTOM, //!< 左下
OP_RIGHTBOTTOM, //!< 右下
};
// コンストラクタ、デストラクタ
public:
COGLJText(const TCHAR* pszFontName, float fFontSize, EORIGINALPOS eOriginPos = OP_LEFTBOTTOM);
virtual ~COGLJText();
// メンバ変数
public:
protected:
private:
TCHAR m_szFontName[LF_FACESIZE]; //!< フォント名(LOGFONTのlfFaceNameの仕様により、文字列の長さはヌル文字含めてLF_FACESIZE(=32))
float m_fFontSize; //!< フォントサイズ
EORIGINALPOS m_eOriginPos; //!< 基点位置
HFONT m_hFont; //!< フォントハンドル
GLuint m_uiDisplayListIndex; //!< ディスプレイリストインデックス
TCHAR* m_pszString; //!< 描画文字列
// メンバ関数
public:
//↓↓↓アクセサ↓↓↓
float GetFontSize() const { return m_fFontSize; } //!< フォントサイズの取得
void SetFontSize(float fFontSize)
{
if (m_fFontSize == fFontSize) { return; }
DeleteDisplayList();
if (m_hFont) { DeleteObject(m_hFont); m_hFont = NULL; }
m_fFontSize = fFontSize;
} //!< フォントサイズの設定
const TCHAR* GetFontName() const { return m_szFontName; } //!< フォント名の取得
void SetFontName(const TCHAR* pszFontName)
{
if (NULL != pszFontName && 0 == _tcscmp(m_szFontName, pszFontName)) { return; }
DeleteDisplayList();
if (m_hFont) { DeleteObject(m_hFont); m_hFont = NULL; }
if (NULL == pszFontName
|| 0 == _tcscmp(_T(""), pszFontName))
{
_tcsncpy_s(m_szFontName, LF_FACESIZE, _T("MS ゴシック"), _TRUNCATE);
}
else
{
_tcsncpy_s(m_szFontName, LF_FACESIZE, pszFontName, _TRUNCATE);
}
} //!< フォント名の設定
EORIGINALPOS GetOriginPos() const { return m_eOriginPos; } //!< 基点位置の取得
void SetOriginPos(const EORIGINALPOS eOriginPos) { m_eOriginPos = eOriginPos; } //!< 基点位置の設定
//↑↑↑アクセサ↑↑↑
public:
void Format(const TCHAR* fmt, ...);
void Render();
protected:
private:
void DeleteDisplayList();
};