/*---------------------------------------------------------------------------* Project: Horizon File: demo_TextsRenderData.h Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 46365 $ *---------------------------------------------------------------------------*/ #ifndef DEMO_TEXTS_RENDER_DATA_H_ #define DEMO_TEXTS_RENDER_DATA_H_ #include "demo/RenderData/demo_TrianglesRenderData.h" namespace demo { /*! :private S-direction offset value for font texture */ const f32 FONT_OFFSET_S = 0.125f; /*! :private T-direction offset value for font texture */ const f32 FONT_OFFSET_T = 0.0625f; /*! :private Base size for font texture */ const u32 FONT_BASE_SIZE = 8; /*! :private Maximum number of characters that can be output on one line */ const u32 MAX_CHAR_LENGTH_PER_LINE = 256; /*! :private Maximum number of characters that can be output */ const u32 MAX_TEXT_LENGTH = MAX_TRIANGLES_NUM / 2; /*! :private @brief Class for rendering data to render text. */ class TextsRenderData : public demo::TrianglesRenderData { public: /*! :private @brief Constructor. */ TextsRenderData(void); /*! :private @brief Destructor. */ virtual ~TextsRenderData(void); public: /*! :private @brief Initializes the rendering data. */ virtual void Initialize(void); /*! :private @brief Finalizes the rendering data. */ virtual void Finalize(void); public: /*! :private @brief Performs initialization for the vertex buffer. @param[in] vertexAttributes Bitwise OR of vertex attributes @param[in] triangleType Type of triangle primitive to render */ void InitializeVertexBuffers(const u32 vertexAttributes, const GLenum triangleType, const u32 maxTextLength); protected: void SetMaxTextLength(const u32 maxTextLength); public: /*! :private @brief Add the text to render to the rendering data. @param[in] windowCoordinateX X-coordinate of the top-left of the rectangle in the window coordinate system where the text is rendered (f32 range) @param[in] windowCoordinateY Y-coordinate of the top-left of the rectangle in the window coordinate system where the text is rendered (f32 range) @param[in] text String for rendering text @param[in] textLength Length of rendering text string @param[in] normalizedDeviceCoordinateZ Z-coordinate in normalized device coordinates for text */ void AddText(const f32 windowCoordinateX, const f32 windowCoordinateY, const char* text, const u32 textLength, const f32 normalizedDeviceCoordinateZ); public: /*! :private @brief Clears packed text data for rendering. */ void ClearPackedTextLength(void); protected: void SetPackedTextLength(const u32 packedTextLength); public: /*! :private @brief Gets length of packed text data for rendering. */ u32 GetPackedTextLength(void) const; public: /*! :private @brief Sets size of font to be rendered. @param[in] fontSize Font size */ void SetFontSize(const f32 fontSize); /*! :private @brief Sets color of font to be rendered. @param[in] red Red component of font color @param[in] green Green component of font color @param[in] blue Blue component of font color @param[in] alpha Alpha component of font color */ void SetFontColor(const f32 red, const f32 green, const f32 blue, const f32 alpha); protected: u32 m_PackedTextLength; u32 m_MaxTextLength; f32 m_FontSize; f32 m_Color[4]; protected: u32 m_FontBaseSize; f32 m_FontOffsetS; f32 m_FontOffsetT; }; } #endif