1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: demo_TextsRenderData.h 4 5 Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 46365 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef DEMO_TEXTS_RENDER_DATA_H_ 17 #define DEMO_TEXTS_RENDER_DATA_H_ 18 19 #include "demo/RenderData/demo_TrianglesRenderData.h" 20 21 namespace demo 22 { 23 24 /*! 25 :private 26 27 S-direction offset value for font texture 28 */ 29 const f32 FONT_OFFSET_S = 0.125f; 30 31 /*! 32 :private 33 34 T-direction offset value for font texture 35 */ 36 const f32 FONT_OFFSET_T = 0.0625f; 37 38 /*! 39 :private 40 41 Base size for font texture 42 */ 43 const u32 FONT_BASE_SIZE = 8; 44 45 /*! 46 :private 47 48 Maximum number of characters that can be output on one line 49 */ 50 const u32 MAX_CHAR_LENGTH_PER_LINE = 256; 51 52 /*! 53 :private 54 55 Maximum number of characters that can be output 56 */ 57 const u32 MAX_TEXT_LENGTH = MAX_TRIANGLES_NUM / 2; 58 59 /*! 60 :private 61 62 @brief Class for rendering data to render text. 63 */ 64 65 class TextsRenderData : public demo::TrianglesRenderData 66 { 67 public: 68 /*! 69 :private 70 71 @brief Constructor. 72 */ 73 TextsRenderData(void); 74 75 /*! 76 :private 77 78 @brief Destructor. 79 */ 80 virtual ~TextsRenderData(void); 81 82 public: 83 /*! 84 :private 85 86 @brief Initializes the rendering data. 87 */ 88 virtual void Initialize(void); 89 90 /*! 91 :private 92 93 @brief Finalizes the rendering data. 94 */ 95 virtual void Finalize(void); 96 97 public: 98 /*! 99 :private 100 101 @brief Performs initialization for the vertex buffer. 102 103 @param[in] vertexAttributes Bitwise OR of vertex attributes 104 @param[in] triangleType Type of triangle primitive to render 105 */ 106 void InitializeVertexBuffers(const u32 vertexAttributes, const GLenum triangleType, const u32 maxTextLength); 107 protected: 108 void SetMaxTextLength(const u32 maxTextLength); 109 110 public: 111 /*! 112 :private 113 114 @brief Add the text to render to the rendering data. 115 116 @param[in] windowCoordinateX X-coordinate of the top-left of the rectangle in the window coordinate system where the text is rendered (f32 range) 117 @param[in] windowCoordinateY Y-coordinate of the top-left of the rectangle in the window coordinate system where the text is rendered (f32 range) 118 @param[in] text String for rendering text 119 @param[in] textLength Length of rendering text string 120 @param[in] normalizedDeviceCoordinateZ Z-coordinate in normalized device coordinates for text 121 */ 122 void AddText(const f32 windowCoordinateX, const f32 windowCoordinateY, 123 const char* text, const u32 textLength, const f32 normalizedDeviceCoordinateZ); 124 125 public: 126 /*! 127 :private 128 129 @brief Clears packed text data for rendering. 130 */ 131 void ClearPackedTextLength(void); 132 protected: 133 void SetPackedTextLength(const u32 packedTextLength); 134 public: 135 /*! 136 :private 137 138 @brief Gets length of packed text data for rendering. 139 */ 140 u32 GetPackedTextLength(void) const; 141 142 public: 143 /*! 144 :private 145 146 @brief Sets size of font to be rendered. 147 148 @param[in] fontSize Font size 149 */ 150 void SetFontSize(const f32 fontSize); 151 152 /*! 153 :private 154 155 @brief Sets color of font to be rendered. 156 157 @param[in] red Red component of font color 158 @param[in] green Green component of font color 159 @param[in] blue Blue component of font color 160 @param[in] alpha Alpha component of font color 161 */ 162 void SetFontColor(const f32 red, const f32 green, 163 const f32 blue, const f32 alpha); 164 165 protected: 166 u32 m_PackedTextLength; 167 u32 m_MaxTextLength; 168 169 f32 m_FontSize; 170 f32 m_Color[4]; 171 172 protected: 173 u32 m_FontBaseSize; 174 f32 m_FontOffsetS; 175 f32 m_FontOffsetT; 176 }; 177 178 } 179 180 #endif 181