Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
textdraw.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19/***************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***************************************************************************
22 * *
23 * Project Name : Commando *
24 * *
25 * $Archive:: /Commando/Code/ww3d2/textdraw.h $*
26 * *
27 * $Author:: Greg_h $*
28 * *
29 * $Modtime:: 3/15/01 3:41p $*
30 * *
31 * $Revision:: 4 $*
32 * *
33 *-------------------------------------------------------------------------*/
34
35
36#if defined(_MSC_VER)
37#pragma once
38#endif
39
40#ifndef TEXTDRAW_H
41#define TEXTDRAW_H
42
43#include "always.h"
44#include "dynamesh.h"
45
46// sgc : wwlib and wwmath contain different rect.h files...
47#include "..\wwmath\rect.h"
48
50
51/******************************************************************
52**
53** TextDrawClass
54**
55** This class provides a simple method to draw 2D text into a scene.
56** Both strings and individual characters can be drawn to any normalized
57** screen coordinates ( 0.. 1 ), or any scale/offset.
58** This class uses a dynamic mesh for all polygon and vertex management
59**
60*******************************************************************/
61
63{
64
65public:
66 /*
67 ** Constructor and Destructor
68 */
69 TextDrawClass( int max_chars );
71
72 // Set Coordinate Range
73 void Set_Coordinate_Ranges( const Vector2 & param_ul, const Vector2 & param_lr,
74 const Vector2 & dest_ul, const Vector2 & dest_lr );
75
76 // Reset all polys and verts
77 virtual void Reset( void );
78
79 /*
80 ** class id of this render object
81 */
82 virtual int Class_ID(void) const { return CLASSID_TEXTDRAW; }
83
84 /*
85 **
86 */
87 float Get_Width( Font3DInstanceClass *font, const char *message );
88 float Get_Char_Width( Font3DInstanceClass *font, const char c );
90 float Get_Height( Font3DInstanceClass *font, const char *message = "" );
91
92 /*
93 ** Print the given char/string with the given font at the given loation in screen pixels
94 ** returns the pixel width of the drawn data.
95 */
96 float Print( Font3DInstanceClass *font, char ch, float screen_x, float screen_y);
97 float Print( Font3DInstanceClass *font, const char *message, float screen_x, float screen_y);
98
99 void Set_Text_Color( const Vector3 & color ) { Set_Vertex_Color(color); }
100
101 /*
102 ** dump the font image (debuging)
103 */
104 void Show_Font( Font3DInstanceClass *font, float screen_x, float screen_y );
105
106 void Quad( float x0, float y0, float x1, float y1, float u0 = 0, float v0 = 0, float u1 = 1, float v1 = 1);
107 void Quad( const RectClass & rect, const RectClass & uv = RectClass( 0, 0, 1, 1 ) );
108 void Line( const Vector2 & a, const Vector2 & b, float width );
109 void Line_Ends( const Vector2 & a, const Vector2 & b, float width, float end_percent );
110
111private:
112 Vector3 TextColor;
113 VertexMaterialClass *DefaultVertexMaterial;
114 ShaderClass DefaultShader;
115 Vector2 TranslateScale;
116 Vector2 TranslateOffset;
118};
119
120#endif // TEXTDRAW_H
unsigned int PixelSize(const SurfaceClass::SurfaceDescription &sd)
DynamicMeshClass(int max_poly, int max_vert)
Definition dynamesh.cpp:521
int Set_Vertex_Color(const Vector4 &color, int color_array_index=0)
Definition dynamesh.h:505
void Quad(float x0, float y0, float x1, float y1, float u0=0, float v0=0, float u1=1, float v1=1)
Definition textdraw.cpp:120
float Print(Font3DInstanceClass *font, char ch, float screen_x, float screen_y)
Definition textdraw.cpp:234
void Show_Font(Font3DInstanceClass *font, float screen_x, float screen_y)
Definition textdraw.cpp:335
virtual void Reset(void)
Definition textdraw.cpp:89
float Get_Char_Width(Font3DInstanceClass *font, const char c)
void Set_Coordinate_Ranges(const Vector2 &param_ul, const Vector2 &param_lr, const Vector2 &dest_ul, const Vector2 &dest_lr)
Definition textdraw.cpp:103
virtual int Class_ID(void) const
Definition textdraw.h:82
void Line(const Vector2 &a, const Vector2 &b, float width)
Definition textdraw.cpp:148
float Get_Width(Font3DInstanceClass *font, const char *message)
Definition textdraw.cpp:197
TextDrawClass(int max_chars)
Definition textdraw.cpp:49
float Get_Inter_Char_Width(Font3DInstanceClass *font)
Definition textdraw.cpp:211
float Get_Height(Font3DInstanceClass *font, const char *message="")
Definition textdraw.cpp:218
void Line_Ends(const Vector2 &a, const Vector2 &b, float width, float end_percent)
Definition textdraw.cpp:174
void Set_Text_Color(const Vector3 &color)
Definition textdraw.h:99