00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00020
00021 #ifndef __VR3TEXT_H__
00022 #define __VR3TEXT_H__
00023
00024
00025 #if defined(_WIN32) || defined(_WIN64)
00026
00027 #include <Windows.h>
00028 #include <string>
00029
00030 #include <map>
00031
00033
00097 class VR3Text {
00098
00100 std::string m_string;
00102 GLfloat m_color[4];
00104 GLfloat m_pos[3];
00106 GLfloat m_scale[2];
00108 GLfloat m_rotation_matrix[16];
00110 GLfloat m_pivot[3];
00111
00113 bool m_ishidden;
00114
00116 GLuint m_VAO;
00118 GLuint m_VBO;
00119
00121 HDC m_mdc;
00123 HFONT m_font;
00125 std::string m_fontname;
00127 unsigned int m_charset;
00129 int m_border[4];
00131 int m_maxsize;
00132
00134 GLuint m_shader_program;
00136 const GLint* m_unilocs;
00137
00139 GLuint m_textures[256];
00141
00143 GLfloat m_charspace[256];
00144
00146 VR3Text(const VR3Text&);
00148 VR3Text& operator = (const VR3Text&);
00149
00150
00151
00153
00154
00156
00164 void PrepareFont(int resy, const char* fontname, unsigned int charset);
00165
00167
00168
00169
00171
00172
00174
00179 void PrepareVAO();
00180
00182
00183 public:
00184
00185
00186
00188
00189
00191
00204 VR3Text( const char* str,
00205 int resy = VR3TEXT_DEF_RESY,
00206 const char* fontname = VR3TEXT_DEF_FONT,
00207 unsigned int charset = VR3TEXT_DEF_CHARSET );
00208
00210 ~VR3Text();
00211
00213
00214
00215
00217
00218
00220
00230 void LoadText(const char* str);
00231
00233
00247 void UseFont( int resy = VR3TEXT_DEF_RESY,
00248 const char* fontname = VR3TEXT_DEF_FONT,
00249 unsigned int charset = VR3TEXT_DEF_CHARSET,
00250 const char* str = 0 );
00251
00253
00254
00255
00257
00258
00260
00261 void GetColor(GLfloat *color);
00262
00264
00265 void SetColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a = 1.0f);
00266
00268
00271 void SetColor(const GLfloat *color);
00272
00274
00280 void GetPivotPoint(GLfloat* vec);
00281
00283
00293 void SetPivotPoint(GLfloat x, GLfloat y, GLfloat z);
00294
00296
00299 void SetPivotPoint(const GLfloat* vec);
00300
00302
00306 void GetPosition(GLfloat* p);
00307
00309
00316 void SetPosition(GLfloat x, GLfloat y, GLfloat z = 0.0f);
00317
00319
00322 void SetPosition(const GLfloat* point);
00323
00325
00330 void GetScale(GLfloat* s);
00331
00333
00339 void SetScale(GLfloat scx, GLfloat scy);
00340
00342
00345 void SetScale(const GLfloat* s);
00346
00348
00354 void GetRotationMatrix(GLfloat* m);
00355
00357
00362 void SetRotationMatrix(const GLfloat* m);
00363
00365
00368 void Hide() { m_ishidden = true; }
00369
00371
00374 void UnHide() { m_ishidden = false; }
00375
00377
00378
00379
00381
00382
00384
00393 void SetRotation(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
00394
00396
00400 void SetRotation(GLfloat angle, GLfloat* axis)
00401 { SetRotation(angle, axis[0], axis[1], axis[2]); }
00402
00404
00414 void RotateLocal(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
00415
00417
00421 void RotateLocal(GLfloat angle, GLfloat* axis)
00422 { RotateLocal(angle,axis[0],axis[1],axis[2]); }
00423
00425
00435 void RotateGlobal(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
00436
00438
00442 void RotateGlobal(GLfloat angle, const GLfloat* axis)
00443 { RotateGlobal(angle,axis[0],axis[1],axis[2]); }
00444
00446
00453 void TranslateLocal(GLfloat x, GLfloat y, GLfloat z = 0.0f);
00454
00456
00459 void TranslateLocal(const GLfloat* vec)
00460 { TranslateLocal(vec[0],vec[1],vec[2]); }
00461
00463
00470 void TranslateGlobal(GLfloat x, GLfloat y, GLfloat z = 0.0f);
00471
00473
00476 void TranslateGlobal(const GLfloat* vec)
00477 { TranslateGlobal(vec[0],vec[1],vec[2]); }
00478
00480
00481
00482
00484
00485
00487
00494 void Draw3D(int flags = 0);
00495
00497
00503 void Draw2D(int flags = 0);
00504
00506
00507 };
00508
00509 #endif // windows only
00510
00511 #endif