Back to index

nux  3.0.0
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     int DrawColorString(ObjectPtr<FontTexture> Font, int x, int y, const NString &str, const Color &color, bool WriteAlphaChannel, int NumCharacter = 0, int SkipFirstNCharacters = 0);
00047     void PositionString(ObjectPtr<FontTexture> Font, const NString &str, const PageBBox &, StringBBox &, TextAlignment align = eAlignTextCenter, int NumCharacter = 0);
00048     int RenderColorText(ObjectPtr<FontTexture> Font, int x, int y, const NString &Str, const Color &color, bool WriteAlphaChannel, int NumCharacter);
00049     int RenderColorTextLineStatic(ObjectPtr<FontTexture> Font, const PageBBox &pageSize, const NString &Str, const Color &color,
00050                                    bool WriteAlphaChannel, TextAlignment alignment);
00051     int RenderColorTextLineEdit(ObjectPtr<FontTexture> Font, const PageBBox &pageSize, const NString &Str,
00052                                  const Color &TextColor,
00053                                  bool WriteAlphaChannel,
00054                                  const Color &SelectedTextColor,
00055                                  const Color &SelectedTextBackgroundColor,
00056                                  const Color &TextBlinkColor,
00057                                  const Color &CursorColor,
00058                                  bool ShowCursor, unsigned int CursorPosition,
00059                                  int offset = 0, int selection_start = 0, int selection_end = 0);
00060 
00061     int RenderText(ObjectPtr<FontTexture> Font, int x, int y, const NString &str, const Color &color, bool WriteAlphaChannel, int StartCharacter = 0, int NumCharacters = 0);
00062     int RenderTextToBuffer(
00063       float *VertexBuffer, int VBSize,
00064       ObjectPtr<FontTexture> Font, Rect geo, const NString &str, const Color &color, TextAlignment alignment = eAlignTextCenter, int NumCharacter = 0);
00065 
00066   private:
00067     GraphicsEngine& _graphics_engine;
00068     ObjectPtr<IOpenGLPixelShader> _pixel_shader_prog;
00069     ObjectPtr<IOpenGLVertexShader> _vertex_shader_prog;
00070     ObjectPtr<IOpenGLShaderProgram> _shader_prog;
00071 
00072     //ObjectPtr<IOpenGLAsmPixelShader> m_AsmPixelShaderProg;
00073     //ObjectPtr<IOpenGLAsmVertexShader> m_AsmVertexShaderProg;
00074     ObjectPtr<IOpenGLAsmShaderProgram> _asm_shader_prog;
00075 
00076     ObjectPtr<IOpenGLAsmShaderProgram> _asm_font_texture_rect_prog;
00077   };
00078 
00079 }
00080 
00081 #endif //FONTRENDERER_H