nux-0.9.48

NuxGraphics/FontRenderer.h

Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #ifndef FONTRENDERER_H
00024 #define FONTRENDERER_H
00025 
00026 #include "GLResource.h"
00027 
00028 class IOpenGLPixelShader;
00029 
00030 namespace nux
00031 {
00032 
00033   class GraphicsEngine;
00034   class TextureRectangle;
00035   class ICgPixelShader;
00036   class ICgVertexShader;
00037   class TemplateQuadBuffer;
00038   class FontTexture;
00039 
00040   class FontRenderer
00041   {
00042   public:
00043     FontRenderer (GraphicsEngine &OpenGLEngine);
00044     ~FontRenderer();
00045 
00046     GraphicsEngine &m_OpenGLEngine;
00047 
00048     int DrawColorString (ObjectPtr<FontTexture> Font, int x, int y, const NString &str, const Color &color, bool WriteAlphaChannel, int NumCharacter = 0, int SkipFirstNCharacters = 0);
00049 
00050     void PositionString (ObjectPtr<FontTexture> Font, const NString &str, const PageBBox &, StringBBox &, TextAlignment align = eAlignTextCenter, int NumCharacter = 0);
00051     int RenderColorText (ObjectPtr<FontTexture> Font, int x, int y, const NString &Str, const Color &color, bool WriteAlphaChannel, int NumCharacter);
00052     int RenderColorTextLineStatic (ObjectPtr<FontTexture> Font, const PageBBox &pageSize, const NString &Str, const Color &color,
00053                                    bool WriteAlphaChannel, TextAlignment alignment);
00054     int RenderColorTextLineEdit (ObjectPtr<FontTexture> Font, const PageBBox &pageSize, const NString &Str,
00055                                  const Color &TextColor,
00056                                  bool WriteAlphaChannel,
00057                                  const Color &SelectedTextColor,
00058                                  const Color &SelectedTextBackgroundColor,
00059                                  const Color &TextBlinkColor,
00060                                  const Color &CursorColor,
00061                                  bool ShowCursor, unsigned int CursorPosition,
00062                                  int offset = 0, int selection_start = 0, int selection_end = 0);
00063 
00064     int RenderText (ObjectPtr<FontTexture> Font, int x, int y, const NString &str, const Color &color, bool WriteAlphaChannel, int StartCharacter = 0, int NumCharacters = 0);
00065     int RenderTextToBuffer (
00066       float *VertexBuffer, int VBSize,
00067       ObjectPtr<FontTexture> Font, Rect geo, const NString &str, const Color &color, TextAlignment alignment = eAlignTextCenter, int NumCharacter = 0);
00068 
00069   private:
00070     TemplateQuadBuffer *m_QuadBuffer;
00071     ObjectPtr<IOpenGLPixelShader> m_PixelShaderProg;
00072     ObjectPtr<IOpenGLVertexShader> m_VertexShaderProg;
00073     ObjectPtr<IOpenGLShaderProgram> m_ShaderProg;
00074 
00075     //ObjectPtr<IOpenGLAsmPixelShader> m_AsmPixelShaderProg;
00076     //ObjectPtr<IOpenGLAsmVertexShader> m_AsmVertexShaderProg;
00077     ObjectPtr<IOpenGLAsmShaderProgram> m_AsmShaderProg;
00078 
00079     ObjectPtr<IOpenGLAsmShaderProgram> _asm_font_texture_rect_prog;
00080   };
00081 
00082 }
00083 
00084 #endif //FONTRENDERER_H