├── example ├── baub_16.bin ├── baub_16.tga ├── example.png ├── Candy Script_48.bin ├── Candy Script_48.tga ├── Shelley Allegro BT_26.bin ├── Shelley Allegro BT_26.tga ├── CMakeLists.txt ├── example.cpp ├── arial_10_bitmap.h └── arial_10.h ├── textBaker ├── arial.ttf ├── glut32.dll ├── bakeFonts.exe ├── Candy Script.ttf ├── gltext-0.3.1_patch │ ├── src │ │ ├── glTextureGlyph_patch.cpp │ │ ├── AbstractRenderer_patch.h │ │ ├── FTGlyph_patch.h │ │ ├── gltext_patch.h │ │ ├── FTGlyph_patch.cpp │ │ ├── AbstractRenderer.h │ │ ├── FTGlyph.h │ │ ├── GLTextureGlyph.cpp │ │ ├── FTGlyph.cpp │ │ ├── AbstractRenderer_patch.cpp │ │ ├── tga.h │ │ ├── AbstractRenderer.cpp │ │ └── gltext.h │ └── examples │ │ └── bakeFonts │ │ ├── bakeFonts.sln │ │ ├── bakeFonts.cpp │ │ └── bakeFonts.vcproj ├── Shelley Allegro BT.ttf └── README.md ├── .gitattributes ├── CMakeLists.txt ├── .gitignore ├── README.md ├── cmake ├── FindGLEW.cmake └── FindGLUT.cmake ├── OpenGLText.h ├── tga.h └── OpenGLText.cpp /example/baub_16.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/example/baub_16.bin -------------------------------------------------------------------------------- /example/baub_16.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/example/baub_16.tga -------------------------------------------------------------------------------- /example/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/example/example.png -------------------------------------------------------------------------------- /textBaker/arial.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/textBaker/arial.ttf -------------------------------------------------------------------------------- /textBaker/glut32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/textBaker/glut32.dll -------------------------------------------------------------------------------- /textBaker/bakeFonts.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/textBaker/bakeFonts.exe -------------------------------------------------------------------------------- /example/Candy Script_48.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/example/Candy Script_48.bin -------------------------------------------------------------------------------- /example/Candy Script_48.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/example/Candy Script_48.tga -------------------------------------------------------------------------------- /textBaker/Candy Script.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/textBaker/Candy Script.ttf -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/glTextureGlyph_patch.cpp: -------------------------------------------------------------------------------- 1 | 56,57d55 2 | < #undef max 3 | < #undef min 4 | -------------------------------------------------------------------------------- /textBaker/Shelley Allegro BT.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/textBaker/Shelley Allegro BT.ttf -------------------------------------------------------------------------------- /example/Shelley Allegro BT_26.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/example/Shelley Allegro BT_26.bin -------------------------------------------------------------------------------- /example/Shelley Allegro BT_26.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/tlorach/OpenGLText/HEAD/example/Shelley Allegro BT_26.tga -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/AbstractRenderer_patch.h: -------------------------------------------------------------------------------- 1 | 47d46 2 | < void GLTEXT_CALL saveFonts(const char* file); 3 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/FTGlyph_patch.h: -------------------------------------------------------------------------------- 1 | 46d45 2 | < void GLTEXT_CALL render(u8* pixels, int x, int y, int pitch); 3 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/gltext_patch.h: -------------------------------------------------------------------------------- 1 | 259d258 2 | < virtual void GLTEXT_CALL render(u8* pixels, int x, int y, int pitch) = 0; 3 | 356d354 4 | < virtual void GLTEXT_CALL saveFonts(const char* file) = 0; 5 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/FTGlyph_patch.cpp: -------------------------------------------------------------------------------- 1 | 35,46d34 2 | < void FTGlyph::render(u8* pixels, int x, int y, int pitch) 3 | < { 4 | < u8 * p = mPixmap; 5 | < u8 * pdst = pixels + x + pitch*(y+mHeight-1); 6 | < for(int i = 0; i 46 | VERBATIM 47 | ) 48 | endforeach() 49 | endif() 50 | 51 | endmacro() 52 | 53 | 54 | find_package(OpenGL) 55 | # ===============> GLUT 56 | find_package(GLUT) 57 | if(NOT GLUT_FOUND) 58 | message(WARNING "Try to set GLUT_LOCATION") 59 | endif() 60 | # ===============> GLEW 61 | if (NOT APPLE) 62 | find_package(GLEW REQUIRED) 63 | endif() 64 | 65 | add_subdirectory(example) 66 | -------------------------------------------------------------------------------- /textBaker/README.md: -------------------------------------------------------------------------------- 1 | Baking Fonts is aschieved for now with patching GLText 0.3.1 ( http://gltext.sourceforge.net/home.php ) from Ben Scott 2 | 3 | This folder contains the changes I made to finally save the data I needed. 4 | Download freetype (I took 2.3.5-1) and download GLText. Then modify it with the data in this folder. 5 | 6 | I have put a compiled version of it for Windows. Note this application would require to be better and therefore could crash or not work properly. 7 | 8 | bakeFonts.exe < .ttf file > < size > 9 | 10 | this tool will generate 2 possible ways of including the font: 11 | * bin + tga : those 2 files can be used to setup the font 12 | * headers font_xx.h and font_xx_bitmap.h : in this case, everything is generated as include files. this is for the case where one wants to have the font data part of the exe file without any reference to external files. 13 | 14 | Few comments: 15 | ------------ 16 | * I found this tool online, but I could have used anything that would use freetype library. 17 | * One might argue that gltext is exactly doing what I want : display text onscreen with truetype fonts... **but**: 18 | ** This project is rather big for what it does (isn't it ? :-) 19 | ** the C++ design is overkill... at least to me 20 | ** we must link against Freetype library to have it working. This is flexible, of course (becaude we can directly read any .ttf file...), but this is not appropriate for my goal : one might not want to link against freetype library if he targeted Android or iOS... 21 | ** The rendering loop... is not the efficient way to do. Each font is rendered separately. Our approach is to render almost everything in one single drawcall. 22 | 23 | The basic idea behing this patch is to allow me to save a tga file made of the character I need with the right size. a binary file will be created, in which structures of Glyphs are stored. 24 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/examples/bakeFonts/bakeFonts.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace gltext; 5 | 6 | 7 | FontRendererPtr mipRenderer; 8 | 9 | 10 | void drawText(const FontRendererPtr& renderer, std::string text) 11 | { 12 | const int size = renderer->getFont()->getSize(); 13 | const int dpi = renderer->getFont()->getDPI(); 14 | const int width = renderer->getWidth(text.c_str()); 15 | const int height = renderer->getHeight(text.c_str()); 16 | GLTEXT_STREAM(renderer) << text << "\nsize: " << size << " dpi: " << dpi; 17 | } 18 | 19 | void display() 20 | { 21 | glClearColor(0, 0, 0.25f, 1); 22 | glClear(GL_COLOR_BUFFER_BIT); 23 | glMatrixMode(GL_MODELVIEW); 24 | glLoadIdentity(); 25 | 26 | glColor4f(0.75f, 0.75f, 0.75f, 1); 27 | 28 | glTranslatef(50, 50, 0); 29 | 30 | drawText(mipRenderer, "Font Rendered !"); 31 | 32 | glutSwapBuffers(); 33 | } 34 | 35 | void reshape(int width, int height) 36 | { 37 | glViewport(0, 0, width, height); 38 | glMatrixMode(GL_PROJECTION); 39 | glLoadIdentity(); 40 | gluOrtho2D(0, width, height, 0); 41 | } 42 | 43 | void keydown(unsigned char key, int x, int y) 44 | { 45 | if (key == 27 || key == 'q') 46 | { 47 | exit(0); 48 | } 49 | } 50 | 51 | int 52 | main(int argc, char** argv) 53 | { 54 | glutInitWindowSize(640, 480); 55 | glutInitWindowPosition(50, 50); 56 | int argc2 = 1; 57 | glutInit(&argc2, argv);//&argc, argv); 58 | glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); 59 | glutCreateWindow("Simple Example"); 60 | 61 | glutDisplayFunc(display); 62 | glutReshapeFunc(reshape); 63 | glutKeyboardFunc(keydown); 64 | 65 | glEnable(GL_BLEND); 66 | glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 67 | 68 | char *ttfName = "../baub.ttf"; 69 | int sz = 0; 70 | if(argc > 1) 71 | ttfName = argv[1]; 72 | if(argc > 2) 73 | sz = atoi(argv[2]); 74 | if(sz <= 0) 75 | sz = 48; 76 | FontPtr font = OpenFont(ttfName, sz); 77 | if (! font) 78 | { 79 | std::cerr<<"Couldn't create font!"<saveFonts(ttfName); 85 | if (! mipRenderer) 86 | { 87 | std::cerr<<"Couldn't create mipmap font renderer!"< 42 | { 43 | protected: 44 | AbstractRenderer(Font* f); 45 | 46 | public: 47 | void GLTEXT_CALL saveFonts(const char* file); 48 | void GLTEXT_CALL render(const char* text); 49 | int GLTEXT_CALL getWidth(const char* text); 50 | int GLTEXT_CALL getHeight(const char* text); 51 | Font* GLTEXT_CALL getFont(); 52 | 53 | protected: 54 | /** 55 | * Makes a rendered glyph ready for OpenGL based on the given FreeType2 56 | * glyph. 57 | */ 58 | virtual GLGlyph* makeGlyph(Glyph* glyph) = 0; 59 | 60 | protected: 61 | FontPtr mFont; 62 | 63 | GlyphCache mCache; 64 | }; 65 | } 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/FTGlyph.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil c-basic-offset: 3 -*- */ 2 | // vim:cindent:ts=3:sw=3:et:tw=80:sta: 3 | /*************************************************************** gltext-cpr beg 4 | * 5 | * GLText - OpenGL TrueType Font Renderer 6 | * GLText is (C) Copyright 2002 by Ben Scott 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | * 23 | * ----------------------------------------------------------------- 24 | * File: $RCSfile: FTGlyph.h,v $ 25 | * Date modified: $Date: 2003/02/03 19:40:41 $ 26 | * Version: $Revision: 1.4 $ 27 | * ----------------------------------------------------------------- 28 | * 29 | ************************************************************ gltext-cpr-end */ 30 | #ifndef GLTEXT_FTGLYPH_H 31 | #define GLTEXT_FTGLYPH_H 32 | 33 | #include 34 | #include FT_FREETYPE_H 35 | #include FT_GLYPH_H 36 | #include "FTFont.h" 37 | 38 | namespace gltext 39 | { 40 | /** 41 | * C++ wrapper for a FreeType2 glyph handle. 42 | */ 43 | class FTGlyph : public RefImpl 44 | { 45 | public: 46 | void GLTEXT_CALL render(u8* pixels, int x, int y, int pitch); 47 | /// Creates a new glyph from the given font face for the given 48 | /// character. 49 | static FTGlyph* create(FT_Face face, char c); 50 | 51 | FTGlyph(int width, int height, int offx, int offy, 52 | int advance, u8* pixmap, u8* bitmap); 53 | 54 | /// Release the FT2 resources. 55 | ~FTGlyph(); 56 | 57 | int GLTEXT_CALL getWidth(); 58 | int GLTEXT_CALL getHeight(); 59 | int GLTEXT_CALL getXOffset(); 60 | int GLTEXT_CALL getYOffset(); 61 | int GLTEXT_CALL getAdvance(); 62 | void GLTEXT_CALL render(u8* pixels); 63 | void GLTEXT_CALL renderBitmap(u8* pixels); 64 | 65 | private: 66 | int mWidth; 67 | int mHeight; 68 | int mXOffset; 69 | int mYOffset; 70 | int mAdvance; 71 | u8* mPixmap; 72 | u8* mBitmap; 73 | }; 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | cmake_build 3 | 4 | ################# 5 | ## Eclipse 6 | ################# 7 | 8 | *.pydevproject 9 | .project 10 | .metadata 11 | bin/ 12 | tmp/ 13 | *.tmp 14 | *.bak 15 | *.swp 16 | *~.nib 17 | local.properties 18 | .classpath 19 | .settings/ 20 | .loadpath 21 | 22 | # External tool builders 23 | .externalToolBuilders/ 24 | 25 | # Locally stored "Eclipse launch configurations" 26 | *.launch 27 | 28 | # CDT-specific 29 | .cproject 30 | 31 | # PDT-specific 32 | .buildpath 33 | 34 | 35 | ################# 36 | ## Visual Studio 37 | ################# 38 | 39 | ## Ignore Visual Studio temporary files, build results, and 40 | ## files generated by popular Visual Studio add-ons. 41 | 42 | # User-specific files 43 | *.suo 44 | *.user 45 | *.sln.docstates 46 | 47 | # Build results 48 | [Dd]ebug/ 49 | [Rr]elease/ 50 | *_i.c 51 | *_p.c 52 | *.ilk 53 | *.meta 54 | *.obj 55 | *.pch 56 | *.pdb 57 | *.pgc 58 | *.pgd 59 | *.rsp 60 | *.sbr 61 | *.tlb 62 | *.tli 63 | *.tlh 64 | *.tmp 65 | *.vspscc 66 | .builds 67 | *.dotCover 68 | 69 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 70 | #packages/ 71 | 72 | # Visual C++ cache files 73 | ipch/ 74 | *.aps 75 | *.ncb 76 | *.opensdf 77 | *.sdf 78 | 79 | # Visual Studio profiler 80 | *.psess 81 | *.vsp 82 | 83 | # ReSharper is a .NET coding add-in 84 | _ReSharper* 85 | 86 | # Installshield output folder 87 | [Ee]xpress 88 | 89 | # DocProject is a documentation generator add-in 90 | DocProject/buildhelp/ 91 | DocProject/Help/*.HxT 92 | DocProject/Help/*.HxC 93 | DocProject/Help/*.hhc 94 | DocProject/Help/*.hhk 95 | DocProject/Help/*.hhp 96 | DocProject/Help/Html2 97 | DocProject/Help/html 98 | 99 | # Click-Once directory 100 | publish 101 | 102 | # Others 103 | [Bb]in 104 | [Oo]bj 105 | sql 106 | TestResults 107 | *.Cache 108 | ClientBin 109 | stylecop.* 110 | ~$* 111 | *.dbmdl 112 | Generated_Code #added for RIA/Silverlight projects 113 | 114 | # Backup & report files from converting an old project file to a newer 115 | # Visual Studio version. Backup files are not needed, because we have git ;-) 116 | _UpgradeReport_Files/ 117 | Backup*/ 118 | UpgradeLog*.XML 119 | 120 | 121 | 122 | ############ 123 | ## Windows 124 | ############ 125 | 126 | # Windows image file caches 127 | Thumbs.db 128 | 129 | # Folder config file 130 | Desktop.ini 131 | 132 | 133 | ############# 134 | ## Python 135 | ############# 136 | 137 | *.py[co] 138 | 139 | # Packages 140 | *.egg 141 | *.egg-info 142 | dist 143 | build 144 | eggs 145 | parts 146 | bin 147 | var 148 | sdist 149 | develop-eggs 150 | .installed.cfg 151 | 152 | # Installer logs 153 | pip-log.txt 154 | 155 | # Unit test / coverage reports 156 | .coverage 157 | .tox 158 | 159 | #Translations 160 | *.mo 161 | 162 | #Mr Developer 163 | .mr.developer.cfg 164 | 165 | # Mac crap 166 | .DS_Store 167 | 168 | #specific to the project 169 | cmake_built 170 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenGLText 2 | 3 | This pair of cpp and h file provides a very easy way to draw text in OpenGL, *using fonts generated from Truetype fonts*. 4 | 5 | There are many tools and libraries available. But : 6 | * I needed to have a really simple approach 7 | * I certainly didn't want to link against any huge monster, such at Freetype library 8 | * I never got satisfied by any existing tool on their way to batch primitives through OpenGL driver : most are rendering characters one after another (even using immediate mode). Some other might use the deprecated Display List... 9 | * I did *not* need the whole flexibility that freetype offers 10 | * I might want to use this implementation on tablets (Adroid and iOS) 11 | 12 | This file proposes a very simple approach based on a texture Atlas containing all the necessary Fonts for a specific type and size. If more than one type or more than one size is needed, the application will have to work with many instances of the class and related resource. 13 | 14 | The fonts are in a tga file; a binary file is associated, containing all the necessary offsets to work correctly with the texture-font from tga file. 15 | 16 | ## Example on how to use it. 17 | 18 | init time: 19 | ```` 20 | OpenGLText oglText; 21 | ... 22 | if(!oglText.init(font_name, canvas_width, canvas_height)) 23 | return false; 24 | ```` 25 | 26 | render time: 27 | ```` 28 | oglText.beginString(); 29 | float bbStr[2]; 30 | char *tmpStr = "Hello world"; 31 | oglText.stringSize(tmpStr, bbStr); 32 | oglText.drawString(posX - bbStr[0]*0.5, posY - bbStr[1], tmpStr, 0,0xF0F0F0F0); 33 | ... 34 | oglText.endString(); // will render the whole at once 35 | ```` 36 | 37 | # Baking Fonts 38 | 39 | textBaker folder contains few details about this. 40 | 41 | For now, I got a bit 'hacky', here: baking Fonts is aschieved with patching GLText 0.3.1 ( http://gltext.sourceforge.net/home.php ) 42 | 43 | This folder contains the changes I made to finally save the data I needed. 44 | Download freetype (I took 2.3.5-1) and download GLText. Then modify it with the data in this folder. 45 | 46 | I have put a compiled version of it for Windows. Note this application would require to be better and therefore could crash or not work properly. 47 | 48 | bakeFonts.exe < .ttf file > < size > 49 | 50 | Example from the demo : 51 | ![Example](https://github.com/tlorach/OpenGLText/raw/master/example/example.png) 52 | 53 | __Few comments:__ 54 | 55 | * I found this tool online, but I could have used anything that would use freetype library. 56 | * One might argue that gltext is exactly doing what I want : display text onscreen with truetype fonts... **but**: 57 | * This project is rather big for what it does (isn't it ? :-) 58 | * the C++ design is overkill... at least to me 59 | * we must link against Freetype library to have it working. This is flexible, of course (becaude we can directly read any .ttf file...), but this is not appropriate for my goal : one might not want to link against freetype library if he targeted Android or iOS... 60 | * The rendering loop... is not the efficient way to do. Each font is rendered separately. Our approach is to render almost everything in one single drawcall. 61 | 62 | The basic idea behind this patch is to allow me to save a tga file made of the character I need with the right size. a binary file will be created, in which structures of Glyphs are stored. 63 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/examples/bakeFonts/bakeFonts.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 26 | 29 | 32 | 35 | 38 | 41 | 54 | 57 | 60 | 63 | 75 | 78 | 81 | 84 | 87 | 90 | 93 | 96 | 97 | 105 | 108 | 111 | 114 | 117 | 120 | 130 | 133 | 136 | 139 | 152 | 155 | 158 | 161 | 164 | 167 | 170 | 173 | 174 | 175 | 176 | 177 | 178 | 183 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /cmake/FindGLEW.cmake: -------------------------------------------------------------------------------- 1 | # 2 | 3 | # Try to find GLEW library and include path. 4 | # Once done this will define 5 | # 6 | # GLEW_FOUND 7 | # GLEW_INCLUDE_DIR 8 | # GLEW_LIBRARY 9 | # GLEW_SOURCE 10 | # 11 | 12 | include(FindPackageHandleStandardArgs) 13 | 14 | if (WIN32) 15 | find_path( GLEW_INCLUDE_DIR 16 | NAMES 17 | GL/glew.h 18 | PATHS 19 | ${GLEW_LOCATION}/include 20 | $ENV{GLEW_LOCATION}/include 21 | $ENV{PROGRAMFILES}/GLEW/include 22 | ${PROJECT_SOURCE_DIR}/extern/glew/include 23 | ${GLEW_LOCATION} 24 | $ENV{GLEW_LOCATION} 25 | DOC "The directory where GL/glew.h resides" ) 26 | find_file( GLEW_SOURCE 27 | NAMES 28 | glew.c 29 | PATHS 30 | ${GLEW_LOCATION}/src 31 | $ENV{GLEW_LOCATION}/src 32 | $ENV{PROGRAMFILES}/GLEW/src 33 | ${PROJECT_SOURCE_DIR}/extern/glew/src 34 | ${GLEW_LOCATION} 35 | $ENV{GLEW_LOCATION} 36 | DOC "The directory where GL/glew.c resides" ) 37 | if(ARCH STREQUAL "x86") 38 | find_library( GLEW_LIBRARY 39 | NAMES 40 | glew GLEW glew32s glew32 41 | PATHS 42 | ${GLEW_LOCATION}/lib 43 | ${GLEW_LOCATION}/lib/x86 44 | ${GLEW_LOCATION}/lib/win32 45 | ${GLEW_LOCATION}/lib/Release/win32 46 | ${GLEW_LOCATION}/lib/Release MX/win32 47 | $ENV{GLEW_LOCATION}/lib 48 | $ENV{GLEW_LOCATION}/lib/Release/win32 49 | $ENV{GLEW_LOCATION}/lib/Release MX/win32 50 | $ENV{GLEW_LOCATION}/lib/x86 51 | $ENV{GLEW_LOCATION}/lib/win32 52 | $ENV{PROGRAMFILES}/GLEW/lib 53 | $ENV{PROGRAMFILES}/GLEW/lib/x86 54 | $ENV{PROGRAMFILES}/GLEW/lib/win32 55 | ${PROJECT_SOURCE_DIR}/extern/glew/bin 56 | ${PROJECT_SOURCE_DIR}/extern/glew/lib 57 | ${PROJECT_SOURCE_DIR}/extern/glew/lib/x86 58 | ${PROJECT_SOURCE_DIR}/extern/glew/lib/win32 59 | ${GLEW_LOCATION} 60 | $ENV{GLEW_LOCATION} 61 | DOC "The GLEW library") 62 | else() 63 | find_library( GLEW_LIBRARY 64 | NAMES 65 | glew GLEW glew32s glew32 66 | PATHS 67 | ${GLEW_LOCATION}/lib/x64 68 | ${GLEW_LOCATION}/lib/Release/x64 69 | ${GLEW_LOCATION}/lib/Release MX/x64 70 | $ENV{GLEW_LOCATION}/lib/x64 71 | $ENV{GLEW_LOCATION}/lib/Release/x64 72 | $ENV{GLEW_LOCATION}/lib/Release MX/x64 73 | $ENV{PROGRAMFILES}/GLEW/lib/x64 74 | ${PROJECT_SOURCE_DIR}/extern/glew/bin 75 | ${PROJECT_SOURCE_DIR}/extern/glew/lib/x64 76 | ${GLEW_LOCATION}/lib 77 | $ENV{GLEW_LOCATION}/lib 78 | $ENV{PROGRAMFILES}/GLEW/lib 79 | ${PROJECT_SOURCE_DIR}/extern/glew/lib 80 | ${GLEW_LOCATION} 81 | $ENV{GLEW_LOCATION} 82 | DOC "The GLEW library") 83 | endif() 84 | endif () 85 | 86 | if (${CMAKE_HOST_UNIX}) 87 | find_path( GLEW_INCLUDE_DIR 88 | NAMES 89 | GL/glew.h 90 | PATHS 91 | ${GLEW_LOCATION}/include 92 | $ENV{GLEW_LOCATION}/include 93 | /usr/include 94 | /usr/local/include 95 | /sw/include 96 | /opt/local/include 97 | NO_DEFAULT_PATH 98 | DOC "The directory where GL/glew.h resides" 99 | ) 100 | find_library( GLEW_LIBRARY 101 | NAMES 102 | GLEW glew 103 | PATHS 104 | ${GLEW_LOCATION}/lib 105 | $ENV{GLEW_LOCATION}/lib 106 | /usr/lib64 107 | /usr/lib 108 | /usr/local/lib64 109 | /usr/local/lib 110 | /sw/lib 111 | /opt/local/lib 112 | NO_DEFAULT_PATH 113 | DOC "The GLEW library") 114 | endif () 115 | 116 | if (GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h") 117 | 118 | file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" GLEW_4_2 REGEX "^#define GL_VERSION_4_2.*$") 119 | if (GLEW_4_2) 120 | SET(OPENGL_4_2_FOUND TRUE) 121 | else () 122 | message(WARNING 123 | "glew-1.7.0 or newer needed for supporting OpenGL 4.2 dependent features" 124 | ) 125 | endif () 126 | 127 | file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" GLEW_4_3 REGEX "^#define GL_VERSION_4_3.*$") 128 | if (GLEW_4_3) 129 | SET(OPENGL_4_3_FOUND TRUE) 130 | else () 131 | message(WARNING 132 | "glew-1.9.0 or newer needed for supporting OpenGL 4.3 dependent features" 133 | ) 134 | endif () 135 | 136 | endif () 137 | 138 | if(GLEW_SOURCE) 139 | find_package_handle_standard_args(GLEW DEFAULT_MSG 140 | GLEW_INCLUDE_DIR 141 | GLEW_SOURCE 142 | ) 143 | else() 144 | find_package_handle_standard_args(GLEW DEFAULT_MSG 145 | GLEW_INCLUDE_DIR 146 | GLEW_LIBRARY 147 | ) 148 | endif() 149 | 150 | mark_as_advanced( GLEW_FOUND ) 151 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/GLTextureGlyph.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil c-basic-offset: 3 -*- */ 2 | // vim:cindent:ts=3:sw=3:et:tw=80:sta: 3 | /*************************************************************** gltext-cpr beg 4 | * 5 | * GLText - OpenGL TrueType Font Renderer 6 | * GLText is (C) Copyright 2002 by Ben Scott 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | * 23 | * ----------------------------------------------------------------- 24 | * File: $RCSfile: GLTextureGlyph.cpp,v $ 25 | * Date modified: $Date: 2003/04/09 23:43:54 $ 26 | * Version: $Revision: 1.7 $ 27 | * ----------------------------------------------------------------- 28 | * 29 | ************************************************************ gltext-cpr-end */ 30 | #include 31 | #include 32 | #include "GLTextureGlyph.h" 33 | 34 | namespace gltext 35 | { 36 | int nextPowerOf2(int n) 37 | { 38 | int i = 1; 39 | while (i < n) 40 | { 41 | i *= 2; 42 | } 43 | return i; 44 | } 45 | 46 | GLTextureGlyph::GLTextureGlyph(int offx, int offy, 47 | int width, int height, u8* data, 48 | bool mipmap) 49 | : mOffsetX(offx) 50 | , mOffsetY(offy) 51 | , mWidth(width) 52 | , mHeight(height) 53 | { 54 | // Make a texture sized at a power of 2. Require them to be 8x8 55 | // to prevent some funky texture flickering rendering glitches. 56 | #undef max 57 | #undef min 58 | mTexWidth = std::max(8, nextPowerOf2(mWidth)); 59 | mTexHeight = std::max(8, nextPowerOf2(mHeight)); 60 | 61 | // Get a unique texture name for our new texture 62 | glGenTextures(1, &mTexName); 63 | 64 | const int size = mTexWidth * mTexHeight; 65 | u8* pixels = new u8[size]; 66 | memset(pixels, 0, size); 67 | for (int row = 0; row < mHeight; ++row) 68 | { 69 | memcpy(pixels + mTexWidth * row, data + mWidth * row, mWidth); 70 | } 71 | delete[] data; 72 | data = 0; 73 | 74 | // This is basically an expansion of pixels into Luminance/Alpha. 75 | u8* la = new u8[size * 2]; 76 | for (int i = 0; i < size; ++i) 77 | { 78 | la[i * 2 + 0] = (pixels[i] ? 255 : 0); 79 | la[i * 2 + 1] = pixels[i]; 80 | } 81 | delete[] pixels; 82 | pixels = 0; 83 | 84 | // Generate a 2D texture with our image data 85 | glBindTexture(GL_TEXTURE_2D, mTexName); 86 | if (mipmap) 87 | { 88 | gluBuild2DMipmaps( 89 | GL_TEXTURE_2D, 90 | 2, 91 | mTexWidth, 92 | mTexHeight, 93 | GL_LUMINANCE_ALPHA, 94 | GL_UNSIGNED_BYTE, 95 | la); 96 | } 97 | else 98 | { 99 | glTexImage2D( 100 | GL_TEXTURE_2D, 101 | 0, 102 | GL_LUMINANCE_ALPHA, 103 | mTexWidth, 104 | mTexHeight, 105 | 0, 106 | GL_LUMINANCE_ALPHA, 107 | GL_UNSIGNED_BYTE, 108 | la); 109 | } 110 | 111 | delete[] la; 112 | la = 0; 113 | 114 | // Setup clamping and our min/mag filters 115 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); 116 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); 117 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 118 | glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 119 | } 120 | 121 | GLTextureGlyph::~GLTextureGlyph() 122 | { 123 | // Free our texture resource 124 | glDeleteTextures(1, &mTexName); 125 | } 126 | 127 | void GLTextureGlyph::render(int penX, int penY) const 128 | { 129 | // Enable texturing and bind our texture 130 | glPushAttrib(GL_TEXTURE_BIT); 131 | glEnable(GL_TEXTURE_2D); 132 | glBindTexture(GL_TEXTURE_2D, mTexName); 133 | 134 | // Draw the texture-mapped quad 135 | glPushMatrix(); 136 | 137 | // Translate over to the font position 138 | glTranslatef(GLfloat(penX + mOffsetX), GLfloat(penY + mOffsetY), 0); 139 | 140 | float realWidth = float(mWidth) / mTexWidth; 141 | float realHeight = float(mHeight) / mTexHeight; 142 | 143 | glBegin(GL_QUADS); 144 | glTexCoord2f(0, 0); glVertex2i(0, 0); 145 | glTexCoord2f(realWidth, 0); glVertex2i(mWidth, 0); 146 | glTexCoord2f(realWidth, realHeight); glVertex2i(mWidth, mHeight); 147 | glTexCoord2f(0, realHeight); glVertex2i(0, mHeight); 148 | glEnd(); 149 | 150 | glPopMatrix(); 151 | 152 | glPopAttrib(); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /OpenGLText.h: -------------------------------------------------------------------------------- 1 | /* 2 | developed by Tristan Lorach - Copyright (c) 2012 NVIDIA Corporation. All rights reserved. 3 | 4 | TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED 5 | *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS 6 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,IMPLIED WARRANTIES OF 7 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA 8 | OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT, OR 9 | CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS 10 | OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY 11 | OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, 12 | EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 13 | 14 | Please direct any questions to tlorach@nvidia.com (Tristan Lorach) 15 | =================================================================================== 16 | Example on how to use it. 17 | init time: 18 | OpenGLText oglText; 19 | ... 20 | if(!oglText.init(font_name, canvas_width, canvas_height)) 21 | return false; 22 | 23 | render time: 24 | oglText.beginString(); 25 | float bbStr[2]; 26 | char *tmpStr = "Hello world"; 27 | oglText.stringSize(tmpStr, bbStr); 28 | oglText.drawString(posX - bbStr[0]*0.5, posY - bbStr[1], tmpStr, 0,0xF0F0F0F0); 29 | ... 30 | oglText.endString(); // will render the whole at once 31 | */ 32 | #ifndef OpenGLText_H__ 33 | #define OpenGLText_H__ 34 | 35 | #include 36 | 37 | class OpenGLText 38 | { 39 | public: 40 | // 41 | // Header and structure for what is in the .bin file of the font 42 | // 43 | struct GlyphInfo 44 | { 45 | struct Pix // pixel oriented data 46 | { 47 | int u, v; 48 | int width, height; 49 | int advance; 50 | int offX, offY; 51 | }; 52 | struct Norm // normalized data 53 | { 54 | float u, v; // position in the map in normalized coords 55 | float width, height; 56 | float advance; 57 | float offX, offY; 58 | }; 59 | Pix pix; 60 | Norm norm; 61 | }; 62 | struct FileHeader 63 | { 64 | int texwidth, texheight; 65 | struct Pix 66 | { 67 | int ascent; 68 | int descent; 69 | int linegap; 70 | }; 71 | struct Norm 72 | { 73 | float ascent; 74 | float descent; 75 | float linegap; 76 | }; 77 | Pix pix; 78 | Norm norm; 79 | GlyphInfo glyphs[256]; 80 | }; 81 | 82 | OpenGLText(); 83 | ~OpenGLText(); 84 | static void BackupStates(); 85 | static void RestoreStates(); 86 | void beginString(); 87 | void endString(); 88 | void stringSize(const char *text, float *sz); 89 | float drawString( int x, int y, const char * text, int nbLines, unsigned long color); 90 | float drawString( int x, int y, const char * text, int nbLines, float * color4f); 91 | bool init(const char * fontName, int w, int h); 92 | bool init(unsigned char *imageData, FileHeader *glyphInfos, int w, int h); 93 | void changeCanvas(int w, int h); 94 | void changeSize(int w, int h); 95 | private: 96 | bool init(int w, int h); 97 | static char* cWidgetVSSource2; 98 | static char* cWidgetFSSource2; 99 | unsigned int c_fontNbChars; 100 | unsigned int c_fontHeight; 101 | unsigned int c_fontWidth; 102 | unsigned int m_widgetProgram; 103 | unsigned int m_vShader; 104 | unsigned int m_fShader; 105 | unsigned int m_canvasVar; 106 | unsigned int m_color; 107 | unsigned int m_depthNFRSVar; 108 | unsigned int m_fontTex; 109 | float m_vertexDepth; 110 | int m_indexOffset; 111 | unsigned int m_vbo; 112 | unsigned int m_vbosz; 113 | #ifdef USE_FONT_METRIC_AS_TBO 114 | unsigned int m_GlyphTexOffset; 115 | unsigned int m_boGlyphTexOffset; 116 | unsigned int m_texGlyphTexOffset; 117 | unsigned int m_locGlyphTexOffset; 118 | #else 119 | unsigned int locTc; 120 | #endif 121 | #ifdef USE_PSEUDO_INSTANCING 122 | unsigned int m_locQuads; 123 | unsigned int m_texQuads; 124 | #else 125 | unsigned int locPos; 126 | unsigned int locGlyph; 127 | #endif 128 | struct TCanvas 129 | { 130 | float w,h; 131 | float winw,winh; 132 | float ratio; 133 | }; 134 | TCanvas m_canvas; 135 | 136 | struct Vertex 137 | { 138 | float pos[4]; 139 | #ifndef USE_FONT_METRIC_AS_TBO 140 | float tc[4]; 141 | #endif 142 | #ifdef USE_PSEUDO_INSTANCING 143 | float iattr; 144 | float dummy[3]; // to align with the fact we do 2 texelFetch over vec4 145 | #else 146 | int iattr; 147 | #endif 148 | Vertex() 149 | { memset(this, 0, sizeof(Vertex)); } 150 | 151 | void setPos( float fx, float fy, float fz, float fw ) 152 | { 153 | pos[0] = fx; pos[1] = fy; pos[2] = fz; pos[3] = fw; 154 | } 155 | 156 | #ifndef USE_FONT_METRIC_AS_TBO 157 | void setTC( float fx, float fy, float fz, float fw ) 158 | { 159 | tc[0] = fx; tc[1] = fy; tc[2] = fz; tc[3] = fw; 160 | } 161 | #endif 162 | }; 163 | 164 | std::vector< Vertex > m_vertices; 165 | 166 | FileHeader *glyphInfos; 167 | bool allocated; 168 | 169 | GLuint CompileGLSLShader( GLenum target, const char* shader); 170 | GLuint LinkGLSLProgram( GLuint vertexShader, GLuint fragmentShader); 171 | void pushVertex( Vertex* v ); 172 | }; 173 | 174 | #endif 175 | -------------------------------------------------------------------------------- /cmake/FindGLUT.cmake: -------------------------------------------------------------------------------- 1 | # Try to find GLUT library and include path. 2 | # Once done this will define 3 | # 4 | # GLUT_FOUND 5 | # GLUT_INCLUDE_DIR 6 | # GLUT_LIBRARIES 7 | # 8 | 9 | if (WIN32) 10 | if(CYGWIN) 11 | find_path( GLUT_INCLUDE_DIR GL/glut.h 12 | ${GLUT_LOCATION}/include 13 | $ENV{GLUT_LOCATION}/include 14 | /usr/include 15 | ) 16 | if(ARCH STREQUAL "x86") 17 | find_library( GLUT_glut_LIBRARY glut32 freeglut_static freeglut 18 | ${GLUT_LOCATION}/lib 19 | ${GLUT_LOCATION}/lib/win32 20 | ${GLUT_LOCATION}/lib/x86 21 | $ENV{GLUT_LOCATION}/lib 22 | $ENV{GLUT_LOCATION}/lib/win32 23 | $ENV{GLUT_LOCATION}/lib/x86 24 | ${OPENGL_LIBRARY_DIR} 25 | /usr/lib 26 | /usr/lib/w32api 27 | /usr/local/lib 28 | /usr/X11R6/lib 29 | ) 30 | else() 31 | find_library( GLUT_glut_LIBRARY glut32 freeglut_static freeglut 32 | ${GLUT_LOCATION}/lib/x64 33 | $ENV{GLUT_LOCATION}/lib/x64 34 | ${GLUT_LOCATION}/lib 35 | $ENV{GLUT_LOCATION}/lib 36 | ${OPENGL_LIBRARY_DIR} 37 | /usr/lib 38 | /usr/lib/w32api 39 | /usr/local/lib 40 | /usr/X11R6/lib 41 | ) 42 | endif() 43 | else() 44 | find_path( GLUT_INCLUDE_DIR GL/glut.h 45 | ${GLUT_LOCATION}/include 46 | $ENV{GLUT_LOCATION}/include 47 | ${PROJECT_SOURCE_DIR}/extern/glut/include 48 | $ENV{PROGRAMFILES}/GLUT/include 49 | ${OPENGL_INCLUDE_DIR} 50 | DOC "The directory where GL/glut.h resides") 51 | if(ARCH STREQUAL "x86") 52 | find_library( GLUT_glut_LIBRARY 53 | NAMES glut32 glut32s glut freeglut_static freeglut 54 | PATHS 55 | ${GLUT_LOCATION}/lib 56 | ${GLUT_LOCATION}/lib/win32 57 | ${GLUT_LOCATION}/lib/x86 58 | $ENV{GLUT_LOCATION}/lib 59 | $ENV{GLUT_LOCATION}/lib/win32 60 | $ENV{GLUT_LOCATION}/lib/x86 61 | ${PROJECT_SOURCE_DIR}/extern/glut/bin 62 | ${PROJECT_SOURCE_DIR}/extern/glut/lib 63 | ${PROJECT_SOURCE_DIR}/extern/glut/lib/win32 64 | ${PROJECT_SOURCE_DIR}/extern/glut/lib/x86 65 | $ENV{PROGRAMFILES}/GLUT/lib 66 | $ENV{PROGRAMFILES}/GLUT/lib/win32 67 | $ENV{PROGRAMFILES}/GLUT/lib/x86 68 | ${OPENGL_LIBRARY_DIR} 69 | DOC "The GLUT library") 70 | else() 71 | find_library( GLUT_glut_LIBRARY 72 | NAMES glut32 glut32s glut freeglut_static freeglut 73 | PATHS 74 | ${GLUT_LOCATION}/lib/x64 75 | $ENV{GLUT_LOCATION}/lib/x64 76 | ${PROJECT_SOURCE_DIR}/extern/glut/lib/x64 77 | $ENV{PROGRAMFILES}/GLUT/lib/x64 78 | ${GLUT_LOCATION}/lib 79 | $ENV{GLUT_LOCATION}/lib 80 | ${PROJECT_SOURCE_DIR}/extern/glut/bin 81 | ${PROJECT_SOURCE_DIR}/extern/glut/lib 82 | $ENV{PROGRAMFILES}/GLUT/lib 83 | ${OPENGL_LIBRARY_DIR} 84 | DOC "The GLUT library") 85 | endif() 86 | endif() 87 | else () 88 | if (APPLE) 89 | # These values for Apple could probably do with improvement. 90 | find_path( GLUT_INCLUDE_DIR glut.h 91 | /System/Library/Frameworks/GLUT.framework/Versions/A/Headers 92 | ${OPENGL_LIBRARY_DIR} 93 | ) 94 | set(GLUT_glut_LIBRARY "-framework Glut" CACHE STRING "GLUT library for OSX") 95 | set(GLUT_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX") 96 | else () 97 | find_path( GLUT_INCLUDE_DIR GL/glut.h 98 | ${GLUT_LOCATION}/include 99 | $ENV{GLUT_LOCATION}/include 100 | /usr/include 101 | /usr/include/GL 102 | /usr/local/include 103 | /usr/openwin/share/include 104 | /usr/openwin/include 105 | /usr/X11R6/include 106 | /usr/include/X11 107 | /opt/graphics/OpenGL/include 108 | /opt/graphics/OpenGL/contrib/libglut 109 | ) 110 | find_library( GLUT_glut_LIBRARY glut 111 | ${GLUT_LOCATION}/lib 112 | $ENV{GLUT_LOCATION}/lib 113 | /usr/lib 114 | /usr/local/lib 115 | /usr/openwin/lib 116 | /usr/X11R6/lib 117 | ) 118 | find_library( GLUT_Xi_LIBRARY Xi 119 | ${GLUT_LOCATION}/lib 120 | $ENV{GLUT_LOCATION}/lib 121 | /usr/lib 122 | /usr/local/lib 123 | /usr/openwin/lib 124 | /usr/X11R6/lib 125 | ) 126 | find_library( GLUT_Xmu_LIBRARY Xmu 127 | ${GLUT_LOCATION}/lib 128 | $ENV{GLUT_LOCATION}/lib 129 | /usr/lib 130 | /usr/local/lib 131 | /usr/openwin/lib 132 | /usr/X11R6/lib 133 | ) 134 | endif (APPLE) 135 | endif (WIN32) 136 | 137 | set( GLUT_FOUND "NO" ) 138 | 139 | if(GLUT_INCLUDE_DIR) 140 | if(GLUT_glut_LIBRARY) 141 | # Is -lXi and -lXmu required on all platforms that have it? 142 | # If not, we need some way to figure out what platform we are on. 143 | set( GLUT_LIBRARIES 144 | ${GLUT_glut_LIBRARY} 145 | ${GLUT_Xmu_LIBRARY} 146 | ${GLUT_Xi_LIBRARY} 147 | ${GLUT_cocoa_LIBRARY} 148 | ) 149 | set( GLUT_FOUND "YES" ) 150 | 151 | set (GLUT_LIBRARY ${GLUT_LIBRARIES}) 152 | set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR}) 153 | 154 | endif(GLUT_glut_LIBRARY) 155 | endif(GLUT_INCLUDE_DIR) 156 | 157 | include(FindPackageHandleStandardArgs) 158 | 159 | find_package_handle_standard_args(GLUT DEFAULT_MSG 160 | GLUT_INCLUDE_DIR 161 | GLUT_LIBRARIES 162 | ) 163 | 164 | # special case of freeglut requiring a define in static mode 165 | string(FIND ${GLUT_glut_LIBRARY} "freeglut_static.lib" FREEGLUT) 166 | if(FREEGLUT GREATER 0) 167 | message(STATUS "GLUT: using ${GLUT_glut_LIBRARY}") 168 | add_definitions(-DFREEGLUT_STATIC -DFREEGLUT_LIB_PRAGMAS=0) 169 | endif() 170 | 171 | mark_as_advanced( 172 | GLUT_INCLUDE_DIR 173 | GLUT_glut_LIBRARY 174 | GLUT_Xmu_LIBRARY 175 | GLUT_Xi_LIBRARY 176 | ) 177 | 178 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/FTGlyph.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil c-basic-offset: 3 -*- */ 2 | // vim:cindent:ts=3:sw=3:et:tw=80:sta: 3 | /*************************************************************** gltext-cpr beg 4 | * 5 | * GLText - OpenGL TrueType Font Renderer 6 | * GLText is (C) Copyright 2002 by Ben Scott 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | * 23 | * ----------------------------------------------------------------- 24 | * File: $RCSfile: FTGlyph.cpp,v $ 25 | * Date modified: $Date: 2003/02/04 03:31:03 $ 26 | * Version: $Revision: 1.6 $ 27 | * ----------------------------------------------------------------- 28 | * 29 | ************************************************************ gltext-cpr-end */ 30 | #include 31 | #include "FTGlyph.h" 32 | 33 | namespace gltext 34 | { 35 | void FTGlyph::render(u8* pixels, int x, int y, int pitch) 36 | { 37 | u8 * p = mPixmap; 38 | u8 * pdst = pixels + x + pitch*(y+mHeight-1); 39 | for(int i = 0; iglyph, &pxm_glyph); 59 | if (error) 60 | { 61 | return 0; 62 | } 63 | 64 | // copy the unmodified pixmap glyph into a glyph fated to be 65 | // rendered as a bitmap 66 | FT_Glyph btm_glyph; 67 | error = FT_Glyph_Copy(pxm_glyph, &btm_glyph); 68 | if (error) 69 | { 70 | FT_Done_Glyph(pxm_glyph); 71 | return 0; 72 | } 73 | 74 | error = FT_Glyph_To_Bitmap(&pxm_glyph, ft_render_mode_normal, 0, true); 75 | if (error) 76 | { 77 | FT_Done_Glyph(pxm_glyph); 78 | FT_Done_Glyph(btm_glyph); 79 | return 0; 80 | } 81 | 82 | error = FT_Glyph_To_Bitmap(&btm_glyph, ft_render_mode_mono, 0, true); 83 | if (error) 84 | { 85 | FT_Done_Glyph(pxm_glyph); 86 | FT_Done_Glyph(btm_glyph); 87 | return 0; 88 | } 89 | 90 | FT_BitmapGlyph pxm_glyph_bitmap = (FT_BitmapGlyph)pxm_glyph; 91 | FT_BitmapGlyph btm_glyph_bitmap = (FT_BitmapGlyph)btm_glyph; 92 | 93 | int advance = face->glyph->metrics.horiAdvance / 64; 94 | 95 | // use the largest bitmap rendering... 96 | int width = std::max(pxm_glyph_bitmap->bitmap.width, 97 | btm_glyph_bitmap->bitmap.width); 98 | int height = std::max(pxm_glyph_bitmap->bitmap.rows, 99 | btm_glyph_bitmap->bitmap.rows); 100 | 101 | // allocate pixmap and bitmap buffers 102 | u8* pixmap = new u8[width * height]; 103 | u8* bitmap = new u8[width * height]; 104 | 105 | // copy the pixmap bitmap glyph buffer into our local buffer 106 | int pxm_pitch = pxm_glyph_bitmap->bitmap.pitch; 107 | u8* pxm_source = pxm_glyph_bitmap->bitmap.buffer; 108 | for (int i = 0; i < height; ++i) 109 | { 110 | memcpy(pixmap + i * width, pxm_source, width); 111 | pxm_source += pxm_pitch; 112 | } 113 | 114 | // copy the bitmap bitmap glyph buffer into our local buffer 115 | int btm_pitch = btm_glyph_bitmap->bitmap.pitch; 116 | u8* btm_source = btm_glyph_bitmap->bitmap.buffer; 117 | for (int i = 0; i < height; ++i) 118 | { 119 | for (int c = 0; c < width; ++c) 120 | { 121 | int bytePos = i * btm_pitch + (c / 8); 122 | int bit = c % 8; 123 | unsigned char byte = btm_source[bytePos]; 124 | int value = ((byte & (0x80 >> bit)) != 0) * 255; 125 | bitmap[i * width + c] = value; 126 | } 127 | } 128 | 129 | int offx = pxm_glyph_bitmap->left; 130 | int offy = -pxm_glyph_bitmap->top; 131 | 132 | FT_Done_Glyph(pxm_glyph); 133 | FT_Done_Glyph(btm_glyph); 134 | 135 | // FINALLY, create a new glyph object with the decoded pixel buffers 136 | return new FTGlyph(width, height, offx, offy, advance, pixmap, bitmap); 137 | } 138 | 139 | FTGlyph::FTGlyph(int width, int height, int offx, int offy, int advance, 140 | u8* pixmap, u8* bitmap) 141 | { 142 | mWidth = width; 143 | mHeight = height; 144 | mXOffset = offx; 145 | mYOffset = offy; 146 | mAdvance = advance; 147 | mPixmap = pixmap; 148 | mBitmap = bitmap; 149 | } 150 | 151 | FTGlyph::~FTGlyph() 152 | { 153 | delete[] mPixmap; 154 | mPixmap = 0; 155 | delete[] mBitmap; 156 | mBitmap = 0; 157 | } 158 | 159 | int 160 | FTGlyph::getWidth() 161 | { 162 | return mWidth; 163 | } 164 | 165 | int 166 | FTGlyph::getHeight() 167 | { 168 | return mHeight; 169 | } 170 | 171 | int 172 | FTGlyph::getXOffset() 173 | { 174 | return mXOffset; 175 | } 176 | 177 | int 178 | FTGlyph::getYOffset() 179 | { 180 | return mYOffset; 181 | } 182 | 183 | int 184 | FTGlyph::getAdvance() 185 | { 186 | return mAdvance; 187 | } 188 | 189 | void 190 | FTGlyph::render(u8* pixels) 191 | { 192 | memcpy(pixels, mPixmap, mWidth * mHeight); 193 | } 194 | 195 | void 196 | FTGlyph::renderBitmap(u8* pixels) 197 | { 198 | memcpy(pixels, mBitmap, mWidth * mHeight); 199 | } 200 | } 201 | -------------------------------------------------------------------------------- /example/example.cpp: -------------------------------------------------------------------------------- 1 | 2 | #if defined(__APPLE__) 3 | #include 4 | #else 5 | #include 6 | #include 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | #include "../OpenGLText.h" 13 | 14 | #include "arial_10.h" 15 | #include "arial_10_bitmap.h" 16 | 17 | OpenGLText oglText; 18 | OpenGLText oglText2; 19 | OpenGLText oglText3; 20 | OpenGLText oglText4; 21 | 22 | float g_rotate[2] = {0, 0}, 23 | g_prev_x = 0, 24 | g_prev_y = 0, 25 | g_dolly = 5, 26 | g_pan[2] = {0, 0}, 27 | g_center[3] = {0, 0, 0}, 28 | g_size = 0; 29 | 30 | int g_mbutton[3] = {0, 0, 0}; 31 | 32 | int g_width = 800, 33 | g_height = 600; 34 | 35 | //------------------------------------------------------------------------------ 36 | void 37 | reshape(int width, int height) { 38 | 39 | g_width = width; 40 | g_height = height; 41 | oglText.changeSize(g_width, g_height); 42 | oglText.changeCanvas(g_width, g_height); 43 | oglText2.changeSize(g_width, g_height); 44 | oglText2.changeCanvas(g_width, g_height); 45 | oglText3.changeSize(g_width, g_height); 46 | oglText3.changeCanvas(g_width, g_height); 47 | oglText4.changeSize(g_width, g_height); 48 | oglText4.changeCanvas(g_width, g_height); 49 | } 50 | //------------------------------------------------------------------------------ 51 | void 52 | display() { 53 | 54 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 55 | 56 | glViewport(0, 0, g_width, g_height); 57 | glMatrixMode(GL_PROJECTION); 58 | glLoadIdentity(); 59 | glMatrixMode(GL_MODELVIEW); 60 | glLoadIdentity(); 61 | 62 | glDisable(GL_LIGHTING); 63 | glColor3f(1, 1, 1); 64 | glBegin(GL_QUADS); 65 | glColor3f(0.5f, 0.5f, 0.5f); 66 | glVertex3f(-1, -1, 1); 67 | glVertex3f( 1, -1, 1); 68 | glColor3f(0, 0, 0); 69 | glVertex3f( 1, 1, 1); 70 | glVertex3f(-1, 1, 1); 71 | glEnd(); 72 | 73 | double aspect = g_width/(double)g_height; 74 | glMatrixMode(GL_PROJECTION); 75 | glLoadIdentity(); 76 | gluPerspective(45.0, aspect, 0.01, 500.0); 77 | glMatrixMode(GL_MODELVIEW); 78 | glLoadIdentity(); 79 | glTranslatef(-g_pan[0], -g_pan[1], -g_dolly); 80 | glRotatef(g_rotate[1], 1, 0, 0); 81 | glRotatef(g_rotate[0], 0, 1, 0); 82 | glTranslatef(-g_center[0], -g_center[1], -g_center[2]); 83 | glRotatef(-90, 1, 0, 0); // z-up model 84 | 85 | oglText.beginString(); 86 | oglText2.beginString(); 87 | 88 | oglText.drawString(10, g_height-100, "Hello World", 1, 0xFFFFFF70); 89 | 90 | oglText2.drawString(10, g_height-180, 91 | "There is a tide in the affairs of men, \n" 92 | "Which taken at the flood, leads on to fortune.\n" 93 | "Omitted, all the voyage of their life is bound \n" 94 | "in shallows and in miseries. On such a full sea are we now afloat.\n" 95 | "And we must take the current when it serves, or lose our ventures.\n" 96 | "William Shakespeare" 97 | , 2, 0xE0E0FFFF); 98 | oglText.endString(); 99 | oglText2.endString(); 100 | 101 | oglText3.beginString(); 102 | oglText3.drawString(10, g_height-350, 103 | "Total : 3 drawcalls (1 Drawcall per font style)" 104 | , 1, 0xFFE0FFA0); 105 | oglText3.endString(); 106 | 107 | oglText4.beginString(); 108 | oglText4.drawString(10, g_height-370, 109 | "(this small font was created from 2 .h files generated by the converter)" 110 | , 1, 0xFFE0FFA0); 111 | oglText4.endString(); 112 | 113 | glutSwapBuffers(); 114 | glutPostRedisplay(); 115 | } 116 | 117 | //------------------------------------------------------------------------------ 118 | void motion(int x, int y) { 119 | 120 | if (g_mbutton[0] && !g_mbutton[1] && !g_mbutton[2]) { 121 | // orbit 122 | g_rotate[0] += x - g_prev_x; 123 | g_rotate[1] += y - g_prev_y; 124 | } else if (!g_mbutton[0] && g_mbutton[1] && !g_mbutton[2]) { 125 | // pan 126 | g_pan[0] -= g_dolly*(x - g_prev_x)/g_width; 127 | g_pan[1] += g_dolly*(y - g_prev_y)/g_height; 128 | } else if (g_mbutton[0] && g_mbutton[1] && !g_mbutton[2]) { 129 | // dolly 130 | g_dolly -= g_dolly*0.01f*(x - g_prev_x); 131 | if(g_dolly <= 0.01) g_dolly = 0.01f; 132 | } 133 | 134 | g_prev_x = float(x); 135 | g_prev_y = float(y); 136 | } 137 | 138 | //------------------------------------------------------------------------------ 139 | void mouse(int button, int state, int x, int y) { 140 | 141 | g_prev_x = float(x); 142 | g_prev_y = float(y); 143 | g_mbutton[button] = !state; 144 | } 145 | 146 | //------------------------------------------------------------------------------ 147 | void quit() { 148 | exit(0); 149 | } 150 | 151 | //------------------------------------------------------------------------------ 152 | void 153 | keyboard(unsigned char key, int x, int y) { 154 | 155 | switch (key) { 156 | case 'q': quit(); 157 | } 158 | } 159 | 160 | //------------------------------------------------------------------------------ 161 | void 162 | idle() { 163 | //glutPostRedisplay(); 164 | } 165 | 166 | //------------------------------------------------------------------------------ 167 | void 168 | initGL() { 169 | glClearColor(0.1f, 0.1f, 0.1f, 1.0f); 170 | glEnable(GL_LIGHT0); 171 | glColor3f(1, 1, 1); 172 | glEnable(GL_DEPTH_TEST); 173 | glDepthFunc(GL_LEQUAL); 174 | 175 | if(!oglText.init("Candy Script_48", g_width, g_height)) 176 | if(!oglText.init(PROJECT_SOURCE_DIR "/Candy Script_48", g_width, g_height)) 177 | exit(1); 178 | if(!oglText2.init("Shelley Allegro BT_26", g_width, g_height)) 179 | if(!oglText2.init(PROJECT_SOURCE_DIR "/Shelley Allegro BT_26", g_width, g_height)) 180 | exit(1); 181 | if(!oglText3.init("baub_16", g_width, g_height)) 182 | if(!oglText3.init(PROJECT_SOURCE_DIR "/baub_16", g_width, g_height)) 183 | exit(1); 184 | if(!oglText4.init(font_10::image, (OpenGLText::FileHeader*)&font_10::font, g_width, g_height)) 185 | exit(1); 186 | 187 | } 188 | 189 | //------------------------------------------------------------------------------ 190 | int main(int argc, char ** argv) { 191 | 192 | glutInit(&argc, argv); 193 | 194 | //glutSetWindowTitle( g_defaultShapes[m].name.c_str() ); 195 | glutInitDisplayMode(GLUT_RGBA |GLUT_DOUBLE | GLUT_DEPTH); 196 | glutInitWindowSize(800, 400); 197 | glutCreateWindow("Text test"); 198 | 199 | glutDisplayFunc(display); 200 | glutReshapeFunc(reshape); 201 | glutMouseFunc(mouse); 202 | glutKeyboardFunc(keyboard); 203 | glutMotionFunc(motion); 204 | glewInit(); 205 | initGL(); 206 | 207 | glutIdleFunc(idle); 208 | glutMainLoop(); 209 | 210 | quit(); 211 | } 212 | 213 | //------------------------------------------------------------------------------ 214 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/AbstractRenderer_patch.cpp: -------------------------------------------------------------------------------- 1 | 33d32 2 | < #include "tga.h" 3 | 41,290d39 4 | < ////////////////////////////////////////////////////////////////// 5 | < // ADDED CODE: 6 | < 7 | < struct GlyphInfo 8 | < { 9 | < struct Pix // pixel oriented data 10 | < { 11 | < int u, v; 12 | < int width, height; 13 | < int advance; 14 | < int offX, offY; 15 | < }; 16 | < struct Norm // normalized data 17 | < { 18 | < float u, v; // position in the map in normalized coords 19 | < float width, height; 20 | < float advance; 21 | < float offX, offY; 22 | < }; 23 | < Pix pix; 24 | < Norm norm; 25 | < }; 26 | < struct FileHeader 27 | < { 28 | < int texwidth, texheight; 29 | < struct Pix 30 | < { 31 | < int ascent; 32 | < int descent; 33 | < int linegap; 34 | < }; 35 | < struct Norm 36 | < { 37 | < float ascent; 38 | < float descent; 39 | < float linegap; 40 | < }; 41 | < Pix pix; 42 | < Norm norm; 43 | < GlyphInfo glyphs[256]; 44 | < }; 45 | < 46 | < static char headerStr[] = "\ 47 | < struct GlyphInfo\n\ 48 | < {\n\ 49 | < struct Pix // pixel oriented data\n\ 50 | < {\n\ 51 | < int u, v;\n\ 52 | < int width, height;\n\ 53 | < int advance;\n\ 54 | < int offX, offY;\n\ 55 | < };\n\ 56 | < struct Norm // normalized data\n\ 57 | < {\n\ 58 | < float u, v; // position in the map in normalized coords\n\ 59 | < float width, height;\n\ 60 | < float advance;\n\ 61 | < float offX, offY;\n\ 62 | < };\n\ 63 | < Pix pix;\n\ 64 | < Norm norm;\n\ 65 | < };\n\ 66 | < struct FileHeader\n\ 67 | < {\n\ 68 | < int texwidth, texheight;\n\ 69 | < struct Pix\n\ 70 | < {\n\ 71 | < int ascent;\n\ 72 | < int descent;\n\ 73 | < int linegap;\n\ 74 | < };\n\ 75 | < struct Norm\n\ 76 | < {\n\ 77 | < float ascent;\n\ 78 | < float descent;\n\ 79 | < float linegap;\n\ 80 | < };\n\ 81 | < Pix pix;\n\ 82 | < Norm norm;\n\ 83 | < GlyphInfo glyphs[256];\n\ 84 | < };\n\ 85 | < static FileHeader font = \n\ 86 | < "; 87 | < 88 | < void GLTEXT_CALL AbstractRenderer::saveFonts(const char* file) 89 | < { 90 | < float fW = 128.0; 91 | < float fH = 512.0; 92 | < char fileName[100]; 93 | < int penX = 1; 94 | < int penY = 1; 95 | < int maxheight = 0; 96 | < static char *text = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_\\`~=+[]{};':\"<>/?,. "; 97 | < const int H = mFont->getAscent() + mFont->getDescent() + mFont->getLineGap(); 98 | < 99 | < // optimize the size of the map 100 | < int texW = 64; 101 | < do { 102 | < texW <<= 1; 103 | < penX = 1; 104 | < penY = 1; 105 | < maxheight = 0; 106 | < for (const char* itr = text; *itr; ++itr) 107 | < { 108 | < Glyph* glyph = mFont->getGlyph(*itr); 109 | < //GLGlyph* drawGlyph = makeGlyph(glyph); 110 | < int width = glyph->getWidth(); 111 | < int height = glyph->getHeight(); 112 | < if(height > maxheight) 113 | < maxheight = height; 114 | < int offX = glyph->getXOffset(); 115 | < int offY = glyph->getYOffset(); 116 | < if(penX + (width+2) >= texW) 117 | < { 118 | < penX = 0; 119 | < penY += maxheight+2; 120 | < maxheight = 0; 121 | < } 122 | < penX += width+2; 123 | < } 124 | < } while((penY > texW)&&(penY > (texW<<1))); 125 | < fH = (float)(penY + maxheight*2); 126 | < fW = (float)texW; 127 | < 128 | < // now write things 129 | < strcpy(fileName, file); 130 | < int i=(int)strlen(fileName)-1; 131 | < while((i > 0)&&(file[i] != '.')) 132 | < i--; 133 | < fileName[i] = '\0'; 134 | < int fileSize = sizeof(FileHeader); 135 | < FileHeader *fileHeader = (FileHeader *)malloc( fileSize ); 136 | < memset(fileHeader, 0, fileSize); 137 | < 138 | < fileHeader->pix.ascent = mFont->getAscent(); 139 | < fileHeader->norm.ascent = (float)mFont->getAscent()/fH; 140 | < 141 | < fileHeader->pix.descent = mFont->getDescent(); 142 | < fileHeader->norm.descent = (float)mFont->getDescent()/fH; 143 | < 144 | < fileHeader->pix.linegap = mFont->getLineGap(); 145 | < fileHeader->norm.linegap = (float)mFont->getLineGap()/fH; 146 | < 147 | < fileHeader->texwidth = (int)fW; 148 | < fileHeader->texheight = (int)fH; 149 | < 150 | < FILE *fh; 151 | < char fileNameBin[100]; 152 | < sprintf(fileNameBin, "%s_%d.bin", fileName, mFont->getSize()); 153 | < if( !(fh = fopen( fileNameBin, "wb" )) ) 154 | < return; 155 | < 156 | < penX = 1; 157 | < penY = 1; 158 | < maxheight = 0; 159 | < u8* data = new u8[fileHeader->texwidth * fileHeader->texheight]; 160 | < memset(data, 0, fileHeader->texwidth * fileHeader->texheight); 161 | < for (const char* itr = text; *itr; ++itr) 162 | < { 163 | < Glyph* glyph = mFont->getGlyph(*itr); 164 | < //GLGlyph* drawGlyph = makeGlyph(glyph); 165 | < int width = glyph->getWidth(); 166 | < int height = glyph->getHeight(); 167 | < if(height > maxheight) 168 | < maxheight = height; 169 | < int offX = glyph->getXOffset(); 170 | < int offY = glyph->getYOffset(); 171 | < if(penX + (width+2) >= fileHeader->texwidth) 172 | < { 173 | < penX = 0; 174 | < penY += maxheight+2; 175 | < maxheight = 0; 176 | < } 177 | < GlyphInfo &g = fileHeader->glyphs[*itr]; 178 | < 179 | < g.pix.advance = glyph->getAdvance(); 180 | < g.norm.advance = (float)glyph->getAdvance()/fW; 181 | < g.pix.u = penX; 182 | < g.pix.v = penY; 183 | < g.norm.u = (float)penX/fW; 184 | < g.norm.v = (float)penY/fH; 185 | < g.pix.width = width; 186 | < g.pix.height = height; 187 | < g.norm.width = (float)width/fW; 188 | < g.norm.height = (float)height/fH; 189 | < g.pix.offX = offX; 190 | < g.pix.offY = offY; 191 | < g.norm.offX = (float)offX/fW; 192 | < g.norm.offY = (float)offY/fH; 193 | < 194 | < glyph->render(data, penX, penY, fileHeader->texwidth); 195 | < penX += width+2; 196 | < } 197 | < fwrite( fileHeader, sizeof (unsigned char), fileSize, fh ); 198 | < fclose( fh ); 199 | < // 200 | < // Write the C version 201 | < // 202 | < sprintf(fileNameBin, "%s_%d.h", fileName, mFont->getSize()); 203 | < if( !(fh = fopen( fileNameBin, "w" )) ) 204 | < return; 205 | < fprintf(fh, "namespace font_%d {\n", /*fileName, */mFont->getSize()); 206 | < fprintf(fh, headerStr); 207 | < fprintf(fh, "{ %d, %d,\n", fileHeader->texwidth, fileHeader->texheight); 208 | < fprintf(fh, "{ %d, %d, %d },\n", fileHeader->pix.ascent, fileHeader->pix.descent, fileHeader->pix.linegap); 209 | < fprintf(fh, "{ %.3ff, %.3ff, %.3ff },\n", fileHeader->norm.ascent, fileHeader->norm.descent, fileHeader->norm.linegap); 210 | < fprintf(fh, "{\n"); 211 | < for (int itr = 0; itr<256; itr++) 212 | < { 213 | < GlyphInfo &g = fileHeader->glyphs[itr]; 214 | < fprintf(fh, "/*%c*/{ { %d, %d, %d, %d, %d, %d, %d },{%.3ff, %.3ff, %.3ff, %.3ff, %.3ff, %.3ff, %.3ff} },\n",isprint(itr) ? itr:' ', 215 | < g.pix.u, g.pix.v, 216 | < g.pix.width, g.pix.height, 217 | < g.pix.advance, 218 | < g.pix.offX, g.pix.offY, 219 | < g.norm.u, g.norm.v, 220 | < g.norm.width, g.norm.height, 221 | < g.norm.advance, 222 | < g.norm.offX, g.norm.offY); 223 | < } 224 | < fprintf(fh, "} };\n}\n"); 225 | < fclose( fh ); 226 | < 227 | < TGA tga; 228 | < char fileNameTGA[100]; 229 | < sprintf(fileNameTGA, "%s_%d.tga", fileName, mFont->getSize()); 230 | < TGA::TGAError err = tga.saveFromExternalData( fileNameTGA, fileHeader->texwidth, fileHeader->texheight, TGA::RGB, data ); 231 | < // 232 | < // 233 | < sprintf(fileNameBin, "%s_%d_bitmap.h", fileName, mFont->getSize()); 234 | < if( !(fh = fopen( fileNameBin, "w" )) ) 235 | < return; 236 | < fprintf(fh, "namespace font_%d {\n", /*fileName, */mFont->getSize()); 237 | < fprintf(fh, " static int imageW = %d;\nstatic int imageH = %d;\n", fileHeader->texwidth, fileHeader->texheight); 238 | < fprintf(fh, " static unsigned char image[] = { //gray-scale image\n"); 239 | < u8 *l = data; 240 | < for(int y=0; ytexheight;y++) 241 | < { 242 | < for(int x=0; xtexwidth;x++) 243 | < { 244 | < fprintf(fh, "%d,", *l); 245 | < l++; 246 | < } 247 | < fprintf(fh, "\n"); 248 | < } 249 | < fprintf(fh, "};\n}\n"); 250 | < fclose( fh ); 251 | < } 252 | < // END OF ADDED CODE 253 | < ////////////////////////////////////////////////////////////////// 254 | -------------------------------------------------------------------------------- /tga.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | //#include 5 | //#include 6 | 7 | class TGA 8 | { 9 | public: 10 | enum TGAFormat 11 | { 12 | RGB = 0x1907, 13 | RGBA = 0x1908, 14 | ALPHA = 0x1906, 15 | UNKNOWN = -1 16 | }; 17 | 18 | enum TGAError 19 | { 20 | TGA_NO_ERROR = 1, // No error 21 | TGA_FILE_NOT_FOUND, // File was not found 22 | TGA_BAD_IMAGE_TYPE, // Color mapped image or image is not uncompressed 23 | TGA_BAD_DIMENSION, // Dimension is not a power of 2 24 | TGA_BAD_BITS, // Image bits is not 8, 24 or 32 25 | TGA_BAD_DATA // Image data could not be loaded 26 | }; 27 | 28 | TGA(void) : 29 | m_texFormat(TGA::UNKNOWN), 30 | m_nImageWidth(0), 31 | m_nImageHeight(0), 32 | m_nImageBits(0), 33 | m_nImageData(NULL) {} 34 | 35 | ~TGA(void); 36 | 37 | TGA::TGAError load( const char *name ); 38 | TGA::TGAError saveFromExternalData( const char *name, int w, int h, TGAFormat fmt, const unsigned char *externalImage ); 39 | 40 | TGAFormat m_texFormat; 41 | int m_nImageWidth; 42 | int m_nImageHeight; 43 | int m_nImageBits; 44 | unsigned char * m_nImageData; 45 | 46 | private: 47 | 48 | int returnError(FILE *s, int error); 49 | unsigned char *getRGBA(FILE *s, int size); 50 | unsigned char *getRGB(FILE *s, int size); 51 | unsigned char *getGray(FILE *s, int size); 52 | void writeRGBA(FILE *s, const unsigned char *externalImage, int size); 53 | void writeRGB(FILE *s, const unsigned char *externalImage, int size); 54 | void writeGrayAsRGB(FILE *s, const unsigned char *externalImage, int size); 55 | void writeGray(FILE *s, const unsigned char *externalImage, int size); 56 | }; 57 | #ifndef TGA_NOIMPL 58 | TGA::~TGA( void ) 59 | { 60 | if( m_nImageData != NULL ) 61 | { 62 | free( m_nImageData ); 63 | m_nImageData = NULL; 64 | } 65 | } 66 | 67 | int TGA::returnError( FILE *s, int error ) 68 | { 69 | // Called when there is an error loading the .tga texture file. 70 | fclose( s ); 71 | return error; 72 | } 73 | 74 | unsigned char *TGA::getRGBA( FILE *s, int size ) 75 | { 76 | // Read in RGBA data for a 32bit image. 77 | unsigned char *rgba; 78 | unsigned char temp; 79 | int bread; 80 | int i; 81 | 82 | rgba = (unsigned char *)malloc( size * 4 ); 83 | 84 | if( rgba == NULL ) 85 | return 0; 86 | 87 | bread = (int)fread( rgba, sizeof (unsigned char), size * 4, s ); 88 | 89 | // TGA is stored in BGRA, make it RGBA 90 | if( bread != size * 4 ) 91 | { 92 | free( rgba ); 93 | return 0; 94 | } 95 | 96 | for( i = 0; i < size * 4; i += 4 ) 97 | { 98 | temp = rgba[i]; 99 | rgba[i] = rgba[i + 2]; 100 | rgba[i + 2] = temp; 101 | } 102 | 103 | m_texFormat = TGA::RGBA; 104 | return rgba; 105 | } 106 | 107 | unsigned char *TGA::getRGB( FILE *s, int size ) 108 | { 109 | // Read in RGB data for a 24bit image. 110 | unsigned char *rgb; 111 | unsigned char temp; 112 | int bread; 113 | int i; 114 | 115 | rgb = (unsigned char*)malloc( size * 3 ); 116 | 117 | if( rgb == NULL ) 118 | return 0; 119 | 120 | bread = (int)fread( rgb, sizeof (unsigned char), size * 3, s ); 121 | 122 | if(bread != size * 3) 123 | { 124 | free( rgb ); 125 | return 0; 126 | } 127 | 128 | // TGA is stored in BGR, make it RGB 129 | for( i = 0; i < size * 3; i += 3 ) 130 | { 131 | temp = rgb[i]; 132 | rgb[i] = rgb[i + 2]; 133 | rgb[i + 2] = temp; 134 | } 135 | 136 | m_texFormat = TGA::RGB; 137 | 138 | return rgb; 139 | } 140 | 141 | unsigned char *TGA::getGray( FILE *s, int size ) 142 | { 143 | // Gets the grayscale image data. Used as an alpha channel. 144 | unsigned char *grayData; 145 | int bread; 146 | 147 | grayData = (unsigned char*)malloc( size ); 148 | 149 | if( grayData == NULL ) 150 | return 0; 151 | 152 | bread = (int)fread( grayData, sizeof (unsigned char), size, s ); 153 | 154 | if( bread != size ) 155 | { 156 | free( grayData ); 157 | return 0; 158 | } 159 | 160 | m_texFormat = TGA::ALPHA; 161 | 162 | return grayData; 163 | } 164 | 165 | TGA::TGAError TGA::load( const char *name ) 166 | { 167 | // Loads up a targa file. Supported types are 8,24 and 32 168 | // uncompressed images. 169 | unsigned char type[4]; 170 | unsigned char info[7]; 171 | FILE *s = NULL; 172 | int size = 0; 173 | 174 | if( !(s = fopen( name, "rb" )) ) 175 | return TGA_FILE_NOT_FOUND; 176 | 177 | fread( &type, sizeof (char), 3, s ); // Read in colormap info and image type, byte 0 ignored 178 | fseek( s, 12, SEEK_SET); // Seek past the header and useless info 179 | fread( &info, sizeof (char), 6, s ); 180 | 181 | if( type[1] != 0 || (type[2] != 2 && type[2] != 3) ) 182 | returnError( s, TGA_BAD_IMAGE_TYPE ); 183 | 184 | m_nImageWidth = info[0] + info[1] * 256; 185 | m_nImageHeight = info[2] + info[3] * 256; 186 | m_nImageBits = info[4]; 187 | 188 | size = m_nImageWidth * m_nImageHeight; 189 | 190 | // Make sure we are loading a supported type 191 | if( m_nImageBits != 32 && m_nImageBits != 24 && m_nImageBits != 8 ) 192 | returnError( s, TGA_BAD_BITS ); 193 | 194 | if( m_nImageBits == 32 ) 195 | m_nImageData = getRGBA( s, size ); 196 | else if( m_nImageBits == 24 ) 197 | m_nImageData = getRGB( s, size ); 198 | else if( m_nImageBits == 8 ) 199 | m_nImageData = getGray( s, size ); 200 | 201 | // No image data 202 | if( m_nImageData == NULL ) 203 | returnError( s, TGA_BAD_DATA ); 204 | 205 | fclose( s ); 206 | 207 | return TGA_NO_ERROR; 208 | } 209 | 210 | void TGA::writeRGBA( FILE *s, const unsigned char *externalImage, int size ) 211 | { 212 | // Read in RGBA data for a 32bit image. 213 | unsigned char *rgba; 214 | int bread; 215 | int i; 216 | 217 | rgba = (unsigned char *)malloc( size * 4 ); 218 | 219 | // switch RGBA to BGRA 220 | for( i = 0; i < size * 4; i += 4 ) 221 | { 222 | rgba[i + 0] = externalImage[i + 2]; 223 | rgba[i + 1] = externalImage[i + 1]; 224 | rgba[i + 2] = externalImage[i + 0]; 225 | rgba[i + 3] = externalImage[i + 3]; 226 | } 227 | 228 | bread = (int)fwrite( rgba, sizeof (unsigned char), size * 4, s ); 229 | free( rgba ); 230 | } 231 | 232 | void TGA::writeRGB( FILE *s, const unsigned char *externalImage, int size ) 233 | { 234 | // Read in RGBA data for a 32bit image. 235 | unsigned char *rgb; 236 | int bread; 237 | int i; 238 | 239 | rgb = (unsigned char *)malloc( size * 3 ); 240 | 241 | // switch RGB to BGR 242 | for( i = 0; i < size * 3; i += 3 ) 243 | { 244 | rgb[i + 0] = externalImage[i + 2]; 245 | rgb[i + 1] = externalImage[i + 1]; 246 | rgb[i + 2] = externalImage[i + 0]; 247 | } 248 | 249 | bread = (int)fwrite( rgb, sizeof (unsigned char), size * 3, s ); 250 | free( rgb ); 251 | } 252 | 253 | void TGA::writeGrayAsRGB( FILE *s, const unsigned char *externalImage, int size ) 254 | { 255 | // Read in RGBA data for a 32bit image. 256 | unsigned char *rgb; 257 | int bread; 258 | int i; 259 | 260 | rgb = (unsigned char *)malloc( size * 3 ); 261 | 262 | // switch RGB to BGR 263 | int j = 0; 264 | for( i = 0; i < size * 3; i += 3, j++ ) 265 | { 266 | rgb[i + 0] = externalImage[j]; 267 | rgb[i + 1] = externalImage[j]; 268 | rgb[i + 2] = externalImage[j]; 269 | } 270 | 271 | bread = (int)fwrite( rgb, sizeof (unsigned char), size * 3, s ); 272 | free( rgb ); 273 | } 274 | 275 | void TGA::writeGray( FILE *s, const unsigned char *externalImage, int size ) 276 | { 277 | // Gets the grayscale image data. Used as an alpha channel. 278 | int bread; 279 | 280 | bread = (int)fwrite( externalImage, sizeof (unsigned char), size, s ); 281 | } 282 | 283 | TGA::TGAError TGA::saveFromExternalData( const char *name, int w, int h, TGA::TGAFormat fmt, const unsigned char *externalImage ) 284 | { 285 | static unsigned char type[] = {0,0,2}; 286 | static unsigned char dummy[] = {0,0,0,0,0,0,0,0,0}; 287 | static unsigned char info[] = {0,0,0,0,0,0}; 288 | FILE *s = NULL; 289 | int size = 0; 290 | 291 | if( !(s = fopen( name, "wb" )) ) 292 | return TGA_FILE_NOT_FOUND; 293 | 294 | fwrite( type, sizeof (char), 3, s ); // Read in colormap info and image type, byte 0 ignored 295 | fwrite( dummy, sizeof (char), 9, s ); // Read in colormap info and image type, byte 0 ignored 296 | 297 | info[0] = w & 0xFF; 298 | info[1] = (w>>8) & 0xFF; 299 | info[2] = h & 0xFF; 300 | info[3] = (h>>8) & 0xFF; 301 | switch(fmt) 302 | { 303 | case ALPHA: 304 | info[4] = 8; 305 | break; 306 | case RGB: 307 | info[4] = 24; 308 | break; 309 | case RGBA: 310 | info[4] = 32; 311 | break; 312 | } 313 | fwrite( info, sizeof (char), 6, s ); 314 | 315 | size = w*h; 316 | switch(fmt) 317 | { 318 | case ALPHA: 319 | writeGray(s, externalImage, size); 320 | break; 321 | case RGB: 322 | writeGrayAsRGB/*writeRGB*/(s, externalImage, size); 323 | break; 324 | case RGBA: 325 | writeRGBA(s, externalImage, size); 326 | break; 327 | } 328 | 329 | fclose( s ); 330 | 331 | return TGA_NO_ERROR; 332 | } 333 | #endif 334 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/tga.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | //#include 5 | //#include 6 | 7 | class TGA 8 | { 9 | public: 10 | enum TGAFormat 11 | { 12 | RGB = 0x1907, 13 | RGBA = 0x1908, 14 | ALPHA = 0x1906, 15 | UNKNOWN = -1 16 | }; 17 | 18 | enum TGAError 19 | { 20 | TGA_NO_ERROR = 1, // No error 21 | TGA_FILE_NOT_FOUND, // File was not found 22 | TGA_BAD_IMAGE_TYPE, // Color mapped image or image is not uncompressed 23 | TGA_BAD_DIMENSION, // Dimension is not a power of 2 24 | TGA_BAD_BITS, // Image bits is not 8, 24 or 32 25 | TGA_BAD_DATA // Image data could not be loaded 26 | }; 27 | 28 | TGA(void) : 29 | m_texFormat(TGA::UNKNOWN), 30 | m_nImageWidth(0), 31 | m_nImageHeight(0), 32 | m_nImageBits(0), 33 | m_nImageData(NULL) {} 34 | 35 | ~TGA(void); 36 | 37 | TGA::TGAError load( const char *name ); 38 | TGA::TGAError saveFromExternalData( const char *name, int w, int h, TGAFormat fmt, const unsigned char *externalImage ); 39 | 40 | TGAFormat m_texFormat; 41 | int m_nImageWidth; 42 | int m_nImageHeight; 43 | int m_nImageBits; 44 | unsigned char * m_nImageData; 45 | 46 | private: 47 | 48 | int returnError(FILE *s, int error); 49 | unsigned char *getRGBA(FILE *s, int size); 50 | unsigned char *getRGB(FILE *s, int size); 51 | unsigned char *getGray(FILE *s, int size); 52 | void writeRGBA(FILE *s, const unsigned char *externalImage, int size); 53 | void writeRGB(FILE *s, const unsigned char *externalImage, int size); 54 | void writeGrayAsRGB(FILE *s, const unsigned char *externalImage, int size); 55 | void writeGray(FILE *s, const unsigned char *externalImage, int size); 56 | }; 57 | 58 | TGA::~TGA( void ) 59 | { 60 | if( m_nImageData != NULL ) 61 | { 62 | free( m_nImageData ); 63 | m_nImageData = NULL; 64 | } 65 | } 66 | 67 | int TGA::returnError( FILE *s, int error ) 68 | { 69 | // Called when there is an error loading the .tga texture file. 70 | fclose( s ); 71 | return error; 72 | } 73 | 74 | unsigned char *TGA::getRGBA( FILE *s, int size ) 75 | { 76 | // Read in RGBA data for a 32bit image. 77 | unsigned char *rgba; 78 | unsigned char temp; 79 | int bread; 80 | int i; 81 | 82 | rgba = (unsigned char *)malloc( size * 4 ); 83 | 84 | if( rgba == NULL ) 85 | return 0; 86 | 87 | bread = (int)fread( rgba, sizeof (unsigned char), size * 4, s ); 88 | 89 | // TGA is stored in BGRA, make it RGBA 90 | if( bread != size * 4 ) 91 | { 92 | free( rgba ); 93 | return 0; 94 | } 95 | 96 | for( i = 0; i < size * 4; i += 4 ) 97 | { 98 | temp = rgba[i]; 99 | rgba[i] = rgba[i + 2]; 100 | rgba[i + 2] = temp; 101 | } 102 | 103 | m_texFormat = TGA::RGBA; 104 | return rgba; 105 | } 106 | 107 | unsigned char *TGA::getRGB( FILE *s, int size ) 108 | { 109 | // Read in RGB data for a 24bit image. 110 | unsigned char *rgb; 111 | unsigned char temp; 112 | int bread; 113 | int i; 114 | 115 | rgb = (unsigned char*)malloc( size * 3 ); 116 | 117 | if( rgb == NULL ) 118 | return 0; 119 | 120 | bread = (int)fread( rgb, sizeof (unsigned char), size * 3, s ); 121 | 122 | if(bread != size * 3) 123 | { 124 | free( rgb ); 125 | return 0; 126 | } 127 | 128 | // TGA is stored in BGR, make it RGB 129 | for( i = 0; i < size * 3; i += 3 ) 130 | { 131 | temp = rgb[i]; 132 | rgb[i] = rgb[i + 2]; 133 | rgb[i + 2] = temp; 134 | } 135 | 136 | m_texFormat = TGA::RGB; 137 | 138 | return rgb; 139 | } 140 | 141 | unsigned char *TGA::getGray( FILE *s, int size ) 142 | { 143 | // Gets the grayscale image data. Used as an alpha channel. 144 | unsigned char *grayData; 145 | int bread; 146 | 147 | grayData = (unsigned char*)malloc( size ); 148 | 149 | if( grayData == NULL ) 150 | return 0; 151 | 152 | bread = (int)fread( grayData, sizeof (unsigned char), size, s ); 153 | 154 | if( bread != size ) 155 | { 156 | free( grayData ); 157 | return 0; 158 | } 159 | 160 | m_texFormat = TGA::ALPHA; 161 | 162 | return grayData; 163 | } 164 | 165 | TGA::TGAError TGA::load( const char *name ) 166 | { 167 | // Loads up a targa file. Supported types are 8,24 and 32 168 | // uncompressed images. 169 | unsigned char type[4]; 170 | unsigned char info[7]; 171 | FILE *s = NULL; 172 | int size = 0; 173 | 174 | if( !(s = fopen( name, "rb" )) ) 175 | return TGA_FILE_NOT_FOUND; 176 | 177 | fread( &type, sizeof (char), 3, s ); // Read in colormap info and image type, byte 0 ignored 178 | fseek( s, 12, SEEK_SET); // Seek past the header and useless info 179 | fread( &info, sizeof (char), 6, s ); 180 | 181 | if( type[1] != 0 || (type[2] != 2 && type[2] != 3) ) 182 | returnError( s, TGA_BAD_IMAGE_TYPE ); 183 | 184 | m_nImageWidth = info[0] + info[1] * 256; 185 | m_nImageHeight = info[2] + info[3] * 256; 186 | m_nImageBits = info[4]; 187 | 188 | size = m_nImageWidth * m_nImageHeight; 189 | 190 | // Make sure we are loading a supported type 191 | if( m_nImageBits != 32 && m_nImageBits != 24 && m_nImageBits != 8 ) 192 | returnError( s, TGA_BAD_BITS ); 193 | 194 | if( m_nImageBits == 32 ) 195 | m_nImageData = getRGBA( s, size ); 196 | else if( m_nImageBits == 24 ) 197 | m_nImageData = getRGB( s, size ); 198 | else if( m_nImageBits == 8 ) 199 | m_nImageData = getGray( s, size ); 200 | 201 | // No image data 202 | if( m_nImageData == NULL ) 203 | returnError( s, TGA_BAD_DATA ); 204 | 205 | fclose( s ); 206 | 207 | return TGA_NO_ERROR; 208 | } 209 | 210 | void TGA::writeRGBA( FILE *s, const unsigned char *externalImage, int size ) 211 | { 212 | // Read in RGBA data for a 32bit image. 213 | unsigned char *rgba; 214 | int bread; 215 | int i; 216 | 217 | rgba = (unsigned char *)malloc( size * 4 ); 218 | 219 | // switch RGBA to BGRA 220 | for( i = 0; i < size * 4; i += 4 ) 221 | { 222 | rgba[i + 0] = externalImage[i + 2]; 223 | rgba[i + 1] = externalImage[i + 1]; 224 | rgba[i + 2] = externalImage[i + 0]; 225 | rgba[i + 3] = externalImage[i + 3]; 226 | } 227 | 228 | bread = (int)fwrite( rgba, sizeof (unsigned char), size * 4, s ); 229 | free( rgba ); 230 | } 231 | 232 | void TGA::writeRGB( FILE *s, const unsigned char *externalImage, int size ) 233 | { 234 | // Read in RGBA data for a 32bit image. 235 | unsigned char *rgb; 236 | int bread; 237 | int i; 238 | 239 | rgb = (unsigned char *)malloc( size * 3 ); 240 | 241 | // switch RGB to BGR 242 | for( i = 0; i < size * 3; i += 3 ) 243 | { 244 | rgb[i + 0] = externalImage[i + 2]; 245 | rgb[i + 1] = externalImage[i + 1]; 246 | rgb[i + 2] = externalImage[i + 0]; 247 | } 248 | 249 | bread = (int)fwrite( rgb, sizeof (unsigned char), size * 3, s ); 250 | free( rgb ); 251 | } 252 | 253 | void TGA::writeGrayAsRGB( FILE *s, const unsigned char *externalImage, int size ) 254 | { 255 | // Read in RGBA data for a 32bit image. 256 | unsigned char *rgb; 257 | int bread; 258 | int i; 259 | 260 | rgb = (unsigned char *)malloc( size * 3 ); 261 | 262 | // switch RGB to BGR 263 | int j = 0; 264 | for( i = 0; i < size * 3; i += 3, j++ ) 265 | { 266 | rgb[i + 0] = externalImage[j]; 267 | rgb[i + 1] = externalImage[j]; 268 | rgb[i + 2] = externalImage[j]; 269 | } 270 | 271 | bread = (int)fwrite( rgb, sizeof (unsigned char), size * 3, s ); 272 | free( rgb ); 273 | } 274 | 275 | void TGA::writeGray( FILE *s, const unsigned char *externalImage, int size ) 276 | { 277 | // Gets the grayscale image data. Used as an alpha channel. 278 | int bread; 279 | 280 | bread = (int)fwrite( externalImage, sizeof (unsigned char), size, s ); 281 | } 282 | 283 | TGA::TGAError TGA::saveFromExternalData( const char *name, int w, int h, TGA::TGAFormat fmt, const unsigned char *externalImage ) 284 | { 285 | static unsigned char type[] = {0,0,2}; 286 | static unsigned char dummy[] = {0,0,0,0,0,0,0,0,0}; 287 | static unsigned char info[] = {0,0,0,0,0,0}; 288 | FILE *s = NULL; 289 | int size = 0; 290 | 291 | if( !(s = fopen( name, "wb" )) ) 292 | return TGA_FILE_NOT_FOUND; 293 | 294 | fwrite( type, sizeof (char), 3, s ); // Read in colormap info and image type, byte 0 ignored 295 | fwrite( dummy, sizeof (char), 9, s ); // Read in colormap info and image type, byte 0 ignored 296 | 297 | info[0] = w & 0xFF; 298 | info[1] = (w>>8) & 0xFF; 299 | info[2] = h & 0xFF; 300 | info[3] = (h>>8) & 0xFF; 301 | switch(fmt) 302 | { 303 | case ALPHA: 304 | info[4] = 8; 305 | break; 306 | case RGB: 307 | info[4] = 24; 308 | break; 309 | case RGBA: 310 | info[4] = 32; 311 | break; 312 | } 313 | fwrite( info, sizeof (char), 6, s ); 314 | 315 | size = w*h; 316 | switch(fmt) 317 | { 318 | case ALPHA: 319 | writeGray(s, externalImage, size); 320 | break; 321 | case RGB: 322 | writeGrayAsRGB/*writeRGB*/(s, externalImage, size); 323 | break; 324 | case RGBA: 325 | writeRGBA(s, externalImage, size); 326 | break; 327 | } 328 | 329 | fclose( s ); 330 | 331 | return TGA_NO_ERROR; 332 | } 333 | 334 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/AbstractRenderer.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil c-basic-offset: 3 -*- */ 2 | // vim:cindent:ts=3:sw=3:et:tw=80:sta: 3 | /*************************************************************** gltext-cpr beg 4 | * 5 | * GLText - OpenGL TrueType Font Renderer 6 | * GLText is (C) Copyright 2002 by Ben Scott 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | * 23 | * ----------------------------------------------------------------- 24 | * File: $RCSfile: AbstractRenderer.cpp,v $ 25 | * Date modified: $Date: 2003/03/11 02:57:08 $ 26 | * Version: $Revision: 1.12 $ 27 | * ----------------------------------------------------------------- 28 | * 29 | ************************************************************ gltext-cpr-end */ 30 | #include 31 | #include 32 | #include "AbstractRenderer.h" 33 | #include "tga.h" 34 | 35 | namespace gltext 36 | { 37 | AbstractRenderer::AbstractRenderer(Font* font) 38 | : mFont(font) 39 | { 40 | } 41 | ////////////////////////////////////////////////////////////////// 42 | // ADDED CODE: 43 | 44 | struct GlyphInfo 45 | { 46 | struct Pix // pixel oriented data 47 | { 48 | int u, v; 49 | int width, height; 50 | int advance; 51 | int offX, offY; 52 | }; 53 | struct Norm // normalized data 54 | { 55 | float u, v; // position in the map in normalized coords 56 | float width, height; 57 | float advance; 58 | float offX, offY; 59 | }; 60 | Pix pix; 61 | Norm norm; 62 | }; 63 | struct FileHeader 64 | { 65 | int texwidth, texheight; 66 | struct Pix 67 | { 68 | int ascent; 69 | int descent; 70 | int linegap; 71 | }; 72 | struct Norm 73 | { 74 | float ascent; 75 | float descent; 76 | float linegap; 77 | }; 78 | Pix pix; 79 | Norm norm; 80 | GlyphInfo glyphs[256]; 81 | }; 82 | 83 | static char headerStr[] = "\ 84 | struct GlyphInfo\n\ 85 | {\n\ 86 | struct Pix // pixel oriented data\n\ 87 | {\n\ 88 | int u, v;\n\ 89 | int width, height;\n\ 90 | int advance;\n\ 91 | int offX, offY;\n\ 92 | };\n\ 93 | struct Norm // normalized data\n\ 94 | {\n\ 95 | float u, v; // position in the map in normalized coords\n\ 96 | float width, height;\n\ 97 | float advance;\n\ 98 | float offX, offY;\n\ 99 | };\n\ 100 | Pix pix;\n\ 101 | Norm norm;\n\ 102 | };\n\ 103 | struct FileHeader\n\ 104 | {\n\ 105 | int texwidth, texheight;\n\ 106 | struct Pix\n\ 107 | {\n\ 108 | int ascent;\n\ 109 | int descent;\n\ 110 | int linegap;\n\ 111 | };\n\ 112 | struct Norm\n\ 113 | {\n\ 114 | float ascent;\n\ 115 | float descent;\n\ 116 | float linegap;\n\ 117 | };\n\ 118 | Pix pix;\n\ 119 | Norm norm;\n\ 120 | GlyphInfo glyphs[256];\n\ 121 | };\n\ 122 | static FileHeader font = \n\ 123 | "; 124 | 125 | void GLTEXT_CALL AbstractRenderer::saveFonts(const char* file) 126 | { 127 | float fW = 128.0; 128 | float fH = 512.0; 129 | char fileName[100]; 130 | int penX = 1; 131 | int penY = 1; 132 | int maxheight = 0; 133 | static char *text = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()-_\\`~=+[]{};':\"<>/?,. "; 134 | const int H = mFont->getAscent() + mFont->getDescent() + mFont->getLineGap(); 135 | 136 | // optimize the size of the map 137 | int texW = 64; 138 | do { 139 | texW <<= 1; 140 | penX = 1; 141 | penY = 1; 142 | maxheight = 0; 143 | for (const char* itr = text; *itr; ++itr) 144 | { 145 | Glyph* glyph = mFont->getGlyph(*itr); 146 | //GLGlyph* drawGlyph = makeGlyph(glyph); 147 | int width = glyph->getWidth(); 148 | int height = glyph->getHeight(); 149 | if(height > maxheight) 150 | maxheight = height; 151 | int offX = glyph->getXOffset(); 152 | int offY = glyph->getYOffset(); 153 | if(penX + (width+2) >= texW) 154 | { 155 | penX = 0; 156 | penY += maxheight+2; 157 | maxheight = 0; 158 | } 159 | penX += width+2; 160 | } 161 | } while((penY > texW)&&(penY > (texW<<1))); 162 | fH = (float)(penY + maxheight*2); 163 | fW = (float)texW; 164 | 165 | // now write things 166 | strcpy(fileName, file); 167 | int i=(int)strlen(fileName)-1; 168 | while((i > 0)&&(file[i] != '.')) 169 | i--; 170 | fileName[i] = '\0'; 171 | int fileSize = sizeof(FileHeader); 172 | FileHeader *fileHeader = (FileHeader *)malloc( fileSize ); 173 | memset(fileHeader, 0, fileSize); 174 | 175 | fileHeader->pix.ascent = mFont->getAscent(); 176 | fileHeader->norm.ascent = (float)mFont->getAscent()/fH; 177 | 178 | fileHeader->pix.descent = mFont->getDescent(); 179 | fileHeader->norm.descent = (float)mFont->getDescent()/fH; 180 | 181 | fileHeader->pix.linegap = mFont->getLineGap(); 182 | fileHeader->norm.linegap = (float)mFont->getLineGap()/fH; 183 | 184 | fileHeader->texwidth = (int)fW; 185 | fileHeader->texheight = (int)fH; 186 | 187 | FILE *fh; 188 | char fileNameBin[100]; 189 | sprintf(fileNameBin, "%s_%d.bin", fileName, mFont->getSize()); 190 | if( !(fh = fopen( fileNameBin, "wb" )) ) 191 | return; 192 | 193 | penX = 1; 194 | penY = 1; 195 | maxheight = 0; 196 | u8* data = new u8[fileHeader->texwidth * fileHeader->texheight]; 197 | memset(data, 0, fileHeader->texwidth * fileHeader->texheight); 198 | for (const char* itr = text; *itr; ++itr) 199 | { 200 | Glyph* glyph = mFont->getGlyph(*itr); 201 | //GLGlyph* drawGlyph = makeGlyph(glyph); 202 | int width = glyph->getWidth(); 203 | int height = glyph->getHeight(); 204 | if(height > maxheight) 205 | maxheight = height; 206 | int offX = glyph->getXOffset(); 207 | int offY = glyph->getYOffset(); 208 | if(penX + (width+2) >= fileHeader->texwidth) 209 | { 210 | penX = 0; 211 | penY += maxheight+2; 212 | maxheight = 0; 213 | } 214 | GlyphInfo &g = fileHeader->glyphs[*itr]; 215 | 216 | g.pix.advance = glyph->getAdvance(); 217 | g.norm.advance = (float)glyph->getAdvance()/fW; 218 | g.pix.u = penX; 219 | g.pix.v = penY; 220 | g.norm.u = (float)penX/fW; 221 | g.norm.v = (float)penY/fH; 222 | g.pix.width = width; 223 | g.pix.height = height; 224 | g.norm.width = (float)width/fW; 225 | g.norm.height = (float)height/fH; 226 | g.pix.offX = offX; 227 | g.pix.offY = offY; 228 | g.norm.offX = (float)offX/fW; 229 | g.norm.offY = (float)offY/fH; 230 | 231 | glyph->render(data, penX, penY, fileHeader->texwidth); 232 | penX += width+2; 233 | } 234 | fwrite( fileHeader, sizeof (unsigned char), fileSize, fh ); 235 | fclose( fh ); 236 | // 237 | // Write the C version 238 | // 239 | sprintf(fileNameBin, "%s_%d.h", fileName, mFont->getSize()); 240 | if( !(fh = fopen( fileNameBin, "w" )) ) 241 | return; 242 | fprintf(fh, "namespace font_%d {\n", /*fileName, */mFont->getSize()); 243 | fprintf(fh, headerStr); 244 | fprintf(fh, "{ %d, %d,\n", fileHeader->texwidth, fileHeader->texheight); 245 | fprintf(fh, "{ %d, %d, %d },\n", fileHeader->pix.ascent, fileHeader->pix.descent, fileHeader->pix.linegap); 246 | fprintf(fh, "{ %.3ff, %.3ff, %.3ff },\n", fileHeader->norm.ascent, fileHeader->norm.descent, fileHeader->norm.linegap); 247 | fprintf(fh, "{\n"); 248 | for (int itr = 0; itr<256; itr++) 249 | { 250 | GlyphInfo &g = fileHeader->glyphs[itr]; 251 | fprintf(fh, "/*%c*/{ { %d, %d, %d, %d, %d, %d, %d },{%.3ff, %.3ff, %.3ff, %.3ff, %.3ff, %.3ff, %.3ff} },\n",isprint(itr) ? itr:' ', 252 | g.pix.u, g.pix.v, 253 | g.pix.width, g.pix.height, 254 | g.pix.advance, 255 | g.pix.offX, g.pix.offY, 256 | g.norm.u, g.norm.v, 257 | g.norm.width, g.norm.height, 258 | g.norm.advance, 259 | g.norm.offX, g.norm.offY); 260 | } 261 | fprintf(fh, "} };\n}\n"); 262 | fclose( fh ); 263 | 264 | TGA tga; 265 | char fileNameTGA[100]; 266 | sprintf(fileNameTGA, "%s_%d.tga", fileName, mFont->getSize()); 267 | TGA::TGAError err = tga.saveFromExternalData( fileNameTGA, fileHeader->texwidth, fileHeader->texheight, TGA::RGB, data ); 268 | // 269 | // 270 | sprintf(fileNameBin, "%s_%d_bitmap.h", fileName, mFont->getSize()); 271 | if( !(fh = fopen( fileNameBin, "w" )) ) 272 | return; 273 | fprintf(fh, "namespace font_%d {\n", /*fileName, */mFont->getSize()); 274 | fprintf(fh, " static int imageW = %d;\nstatic int imageH = %d;\n", fileHeader->texwidth, fileHeader->texheight); 275 | fprintf(fh, " static unsigned char image[] = { //gray-scale image\n"); 276 | u8 *l = data; 277 | for(int y=0; ytexheight;y++) 278 | { 279 | for(int x=0; xtexwidth;x++) 280 | { 281 | fprintf(fh, "%d,", *l); 282 | l++; 283 | } 284 | fprintf(fh, "\n"); 285 | } 286 | fprintf(fh, "};\n}\n"); 287 | fclose( fh ); 288 | } 289 | // END OF ADDED CODE 290 | ////////////////////////////////////////////////////////////////// 291 | 292 | void GLTEXT_CALL AbstractRenderer::render(const char* text) 293 | { 294 | const int ascent = mFont->getAscent(); 295 | const int descent = mFont->getDescent(); 296 | const int height = ascent + descent + mFont->getLineGap(); 297 | 298 | int penX = 0; 299 | int penY = 0; 300 | 301 | unsigned char last_character = 0; 302 | 303 | // Run through each char and generate a glyph to draw 304 | for (const char* itr = text; *itr; ++itr) 305 | { 306 | // newline? 307 | if (*itr == '\n') 308 | { 309 | penX = 0; 310 | penY += height; 311 | continue; 312 | } 313 | 314 | // Get the glyph for the current character 315 | Glyph* fontGlyph = mFont->getGlyph(*itr); 316 | if (!fontGlyph) 317 | { 318 | continue; 319 | } 320 | 321 | // Check the cache first 322 | GLGlyph* drawGlyph = mCache.get(fontGlyph); 323 | if (!drawGlyph) 324 | { 325 | // Cache miss. Ask this renderer to create a new one 326 | drawGlyph = makeGlyph(fontGlyph); 327 | if (!drawGlyph) 328 | { 329 | // AAACK! Couldn't create the glyph. Fail silently. 330 | continue; 331 | } 332 | mCache.put(fontGlyph, drawGlyph); 333 | } 334 | 335 | int kerning = mFont->getKerning(last_character, *itr); 336 | last_character = *itr; 337 | int old_x = penX; 338 | penX += kerning; 339 | 340 | // Now tell the glyph to render itself. 341 | drawGlyph->render(penX, penY); 342 | penX += fontGlyph->getAdvance(); 343 | 344 | // Kerning shouldn't make us draw farther and farther to the 345 | // left... this fixes the "sliding dot problem". 346 | penX = std::max(penX, old_x); 347 | } 348 | } 349 | 350 | int GLTEXT_CALL AbstractRenderer::getWidth(const char* text) 351 | { 352 | if (! text) 353 | { 354 | return 0; 355 | } 356 | 357 | int max_width = 0; 358 | int width = 0; 359 | 360 | unsigned char last_character = 0; 361 | 362 | // Iterate over each character adding its width 363 | for (const char* itr = text; *itr != 0; ++itr) 364 | { 365 | if (*itr == '\n') 366 | { 367 | width = 0; 368 | continue; 369 | } 370 | 371 | // Get the glyph for the current character 372 | Glyph* fontGlyph = mFont->getGlyph(*itr); 373 | if (fontGlyph) 374 | { 375 | int kerning = mFont->getKerning(last_character, *itr); 376 | last_character = *itr; 377 | width += kerning; 378 | 379 | // Add this glyph's advance 380 | width += fontGlyph->getAdvance(); 381 | max_width = std::max(width, max_width); 382 | } 383 | } 384 | 385 | return max_width; 386 | } 387 | 388 | int GLTEXT_CALL AbstractRenderer::getHeight(const char* text) 389 | { 390 | const int ascent = mFont->getAscent(); 391 | const int descent = mFont->getDescent(); 392 | const int height = ascent + descent + mFont->getLineGap(); 393 | return int(std::count(text, text + strlen(text), '\n') + 1) * height; 394 | } 395 | 396 | Font* GLTEXT_CALL AbstractRenderer::getFont() 397 | { 398 | return mFont.get(); 399 | } 400 | } 401 | -------------------------------------------------------------------------------- /textBaker/gltext-0.3.1_patch/src/gltext.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil c-basic-offset: 3 -*- */ 2 | // vim:cindent:ts=3:sw=3:et:tw=80:sta: 3 | /*************************************************************** gltext-cpr beg 4 | * 5 | * GLText - OpenGL TrueType Font Renderer 6 | * GLText is (C) Copyright 2002 by Ben Scott 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 | * Boston, MA 02111-1307, USA. 22 | * 23 | * ----------------------------------------------------------------- 24 | * File: $RCSfile: gltext.h,v $ 25 | * Date modified: $Date: 2003/06/03 22:21:23 $ 26 | * Version: $Revision: 1.25 $ 27 | * ----------------------------------------------------------------- 28 | * 29 | ************************************************************ gltext-cpr-end */ 30 | #ifndef GLTEXT_H 31 | #define GLTEXT_H 32 | 33 | #ifndef __cplusplus 34 | # error GLText requires C++ 35 | #endif 36 | 37 | #include 38 | 39 | // The calling convention for cross-DLL calls in win32 40 | #ifndef GLTEXT_CALL 41 | # ifdef WIN32 42 | # define GLTEXT_CALL __stdcall 43 | # else 44 | # define GLTEXT_CALL 45 | # endif 46 | #endif 47 | 48 | // Export functions from the DLL 49 | #ifndef GLTEXT_DECL 50 | # if defined(WIN32) || defined(_WIN32) 51 | # ifdef GLTEXT_EXPORTS 52 | # define GLTEXT_DECL __declspec(dllexport) 53 | # else 54 | # define GLTEXT_DECL __declspec(dllimport) 55 | # endif 56 | # else 57 | # define GLTEXT_DECL 58 | # endif 59 | #endif 60 | 61 | #define GLTEXT_FUNC(ret) extern "C" GLTEXT_DECL ret GLTEXT_CALL 62 | 63 | namespace gltext 64 | { 65 | typedef unsigned char u8; 66 | 67 | 68 | /** 69 | * Base class for classes the manage their own memory using reference 70 | * counting. 71 | * 72 | * This class was originally written by Chad Austin for the audiere project 73 | * and released under the LGPL. 74 | */ 75 | class RefCounted 76 | { 77 | protected: 78 | /** 79 | * Protected so users of recounted classes don't use std::auto_ptr or the 80 | * delete operator. 81 | * 82 | * Interfaces that derive from RefCounted should define an inline, empty, 83 | * protected destructor as well. 84 | */ 85 | ~RefCounted() {} 86 | 87 | public: 88 | /** 89 | * Add a reference to this object. This will increment the internal 90 | * reference count. 91 | */ 92 | virtual void GLTEXT_CALL ref() = 0; 93 | 94 | /** 95 | * Remove a reference from this object. This will decrement the internal 96 | * reference count. When this count reaches 0, the object is destroyed. 97 | */ 98 | virtual void GLTEXT_CALL unref() = 0; 99 | }; 100 | 101 | /** 102 | * This defines a smart pointer to some type T that implements the RefCounted 103 | * interface. This object will do all the nasty reference counting for you. 104 | * 105 | * This class was originally written by Chad Austin for the audiere project 106 | * and released under the LGPL. 107 | */ 108 | template< typename T > 109 | class RefPtr 110 | { 111 | public: 112 | RefPtr(T* ptr = 0) 113 | { 114 | mPtr = 0; 115 | *this = ptr; 116 | } 117 | 118 | RefPtr(const RefPtr& ptr) 119 | { 120 | mPtr = 0; 121 | *this = ptr; 122 | } 123 | 124 | ~RefPtr() 125 | { 126 | if (mPtr) 127 | { 128 | mPtr->unref(); 129 | mPtr = 0; 130 | } 131 | } 132 | 133 | RefPtr& operator=(T* ptr) 134 | { 135 | if (ptr != mPtr) 136 | { 137 | if (mPtr) 138 | { 139 | mPtr->unref(); 140 | } 141 | mPtr = ptr; 142 | if (mPtr) 143 | { 144 | mPtr->ref(); 145 | } 146 | } 147 | return *this; 148 | } 149 | 150 | RefPtr& operator=(const RefPtr& ptr) 151 | { 152 | *this = ptr.mPtr; 153 | return *this; 154 | } 155 | 156 | T* operator->() const 157 | { 158 | return mPtr; 159 | } 160 | 161 | T& operator*() const 162 | { 163 | return *mPtr; 164 | } 165 | 166 | operator bool() const 167 | { 168 | return (mPtr != 0); 169 | } 170 | 171 | T* get() const 172 | { 173 | return mPtr; 174 | } 175 | 176 | private: 177 | T* mPtr; 178 | }; 179 | 180 | 181 | /** 182 | * A basic implementation of the RefCounted interface. Derive your 183 | * implementations from RefImpl. 184 | * 185 | * This class was originally written by Chad Austin for the audiere project 186 | * and released under the LGPL. 187 | */ 188 | template< class Interface > 189 | class RefImpl : public Interface 190 | { 191 | protected: 192 | RefImpl() 193 | : mRefCount(0) 194 | {} 195 | 196 | /** 197 | * So the implementation can put its destruction logic in the destructor, 198 | * as natural C++ code does. 199 | */ 200 | virtual ~RefImpl() {} 201 | 202 | public: 203 | void GLTEXT_CALL ref() 204 | { 205 | ++mRefCount; 206 | } 207 | 208 | void GLTEXT_CALL unref() 209 | { 210 | if (--mRefCount == 0) 211 | { 212 | delete this; 213 | } 214 | } 215 | 216 | private: 217 | int mRefCount; 218 | }; 219 | 220 | 221 | /// Renderer types supported 222 | enum FontRendererType 223 | { 224 | BITMAP, 225 | PIXMAP, 226 | TEXTURE, 227 | MIPMAP, 228 | }; 229 | 230 | 231 | /// Represents a particular shape in a font used to represent one 232 | /// or more characters. 233 | class Glyph : public RefCounted 234 | { 235 | protected: 236 | ~Glyph() {} 237 | 238 | public: 239 | /// Returns width in pixels 240 | virtual int GLTEXT_CALL getWidth() = 0; 241 | 242 | /// Returns height in pixels. 243 | virtual int GLTEXT_CALL getHeight() = 0; 244 | 245 | /// Returns the X offset of this glyph when it is drawn. 246 | virtual int GLTEXT_CALL getXOffset() = 0; 247 | 248 | /// Returns the Y offset of this glyph when it is drawn. 249 | virtual int GLTEXT_CALL getYOffset() = 0; 250 | 251 | /// Returns the number of pixels the pen should move to the 252 | /// right to draw the next character 253 | virtual int GLTEXT_CALL getAdvance() = 0; 254 | 255 | /// Renders the glyph into a buffer of width * height bytes. A 256 | /// value of 0 means the pixel is transparent; likewise, 255 257 | /// means opaque. 258 | virtual void GLTEXT_CALL render(u8* pixels) = 0; 259 | virtual void GLTEXT_CALL render(u8* pixels, int x, int y, int pitch) = 0; 260 | 261 | /// renderBitmap() is the same as render, except that it only 262 | /// uses values 0 and 255. These bitmaps may look better on 263 | /// two-color displays. 264 | virtual void GLTEXT_CALL renderBitmap(u8* pixels) = 0; 265 | }; 266 | 267 | 268 | /** 269 | * Represents a particular font face. 270 | */ 271 | class Font : public RefCounted 272 | { 273 | protected: 274 | ~Font() {} 275 | 276 | public: 277 | /// Gets the name of this font. 278 | virtual const char* GLTEXT_CALL getName() = 0; 279 | 280 | /** 281 | * Returns the glyph object associated with the character c in 282 | * the font. 283 | */ 284 | virtual Glyph* GLTEXT_CALL getGlyph(unsigned char c) = 0; 285 | 286 | /// Gets the point size of this font. 287 | virtual int GLTEXT_CALL getSize() = 0; 288 | 289 | /** 290 | * Returns the DPI value passed to OpenFont() when this font 291 | * was created. 292 | */ 293 | virtual int GLTEXT_CALL getDPI() = 0; 294 | 295 | /** 296 | * Gets the ascent of this font. This is the distance from the 297 | * baseline to the top of the tallest glyph of this font. 298 | */ 299 | virtual int GLTEXT_CALL getAscent() = 0; 300 | 301 | /** 302 | * Gets the descent of this font. This is the distance from the 303 | * baseline to the bottom of the glyph that descends the most 304 | * from the baseline. 305 | */ 306 | virtual int GLTEXT_CALL getDescent() = 0; 307 | 308 | /** 309 | * Gets the distance that must be placed between two lines of 310 | * text. Thus the baseline to baseline distance can be computed 311 | * as ascent + descent + linegap. 312 | */ 313 | virtual int GLTEXT_CALL getLineGap() = 0; 314 | 315 | /** 316 | * Returns the kerning distance between character c1 and 317 | * character c2. The kerning distance is added to the previous 318 | * character's advance distance. 319 | */ 320 | virtual int GLTEXT_CALL getKerning(unsigned char l, unsigned char r) = 0; 321 | }; 322 | typedef RefPtr FontPtr; 323 | 324 | 325 | /** 326 | * Interface to an object that knows how to render a font. 327 | */ 328 | class FontRenderer : public RefCounted 329 | { 330 | protected: 331 | ~FontRenderer() {} 332 | 333 | public: 334 | /** 335 | * Renders the text in the given string as glyphs using this font 336 | * renderer's current font. 337 | */ 338 | virtual void GLTEXT_CALL render(const char* text) = 0; 339 | 340 | /** 341 | * Computes the width of the given text string if it were to be rendered 342 | * with this renderer. 343 | */ 344 | virtual int GLTEXT_CALL getWidth(const char* text) = 0; 345 | 346 | /** 347 | * Computes the height of the given text string if it were to be 348 | * rendered with this renderer. 349 | */ 350 | virtual int GLTEXT_CALL getHeight(const char* text) = 0; 351 | 352 | /** 353 | * Returns the font used to create this renderer. 354 | */ 355 | virtual Font* GLTEXT_CALL getFont() = 0; 356 | virtual void GLTEXT_CALL saveFonts(const char* file) = 0; 357 | }; 358 | typedef RefPtr FontRendererPtr; 359 | 360 | 361 | /** 362 | * Provides an iostream-like interface to a font renderer. Use as follows: 363 | * Stream(renderer).get() << blah blah blah; 364 | * 365 | * The GLTEXT_STREAM macro may be simpler: 366 | * GLTEXT_STREAM(renderer) << blah blah blah; 367 | */ 368 | class Stream : public std::ostringstream 369 | { 370 | public: 371 | Stream(FontRenderer* r) 372 | : mRenderer(r) 373 | { 374 | } 375 | 376 | Stream(const FontRendererPtr& p) 377 | : mRenderer(p.get()) 378 | { 379 | } 380 | 381 | ~Stream() 382 | { 383 | flush(); 384 | } 385 | 386 | /** 387 | * This is a little trick to convert an rvalue to an lvalue. 388 | * The problem is this: class temporaries created with 389 | * FontStream(r) are rvalues, which means they cannot be 390 | * assigned to FontStream& references. Therefore, temporaries 391 | * cannot be used as arguments to the standard operator<< 392 | * overloads. 393 | * 394 | * However! You CAN call methods on object rvalues and methods 395 | * CAN return lvalues! This method effectively converts *this 396 | * from an rvalue to an lvalue using the syntax: 397 | * FontStream(r).get(). 398 | */ 399 | Stream& get() 400 | { 401 | return *this; 402 | } 403 | 404 | FontRenderer* getRenderer() 405 | { 406 | return mRenderer.get(); 407 | } 408 | 409 | /** 410 | * Calls render() on the associated FontRenderer using the 411 | * string that has been created so far. Then it sets the string 412 | * to empty. flush() is called before any GLText manipulator 413 | * and when the font stream is destroyed. 414 | */ 415 | void flush() 416 | { 417 | mRenderer->render(str().c_str()); 418 | str(""); 419 | } 420 | 421 | private: 422 | FontRendererPtr mRenderer; 423 | }; 424 | 425 | /** 426 | * This generic insertion operator can take any type (but fails if 427 | * the type can't be inserted into a std::ostream) and returns a 428 | * FontStream&. Otherwise, something like |FontStream(...) << 429 | * "blah" << gltextmanip;| would not work, as 'gltextmanip' cannot 430 | * be inserted into a std::ostream. 431 | */ 432 | template 433 | Stream& operator<<(Stream& fs, T t) 434 | { 435 | static_cast(fs) << t; 436 | return fs; 437 | } 438 | 439 | /** 440 | * Flush the font stream and apply the gltext stream manipulator to it. 441 | */ 442 | inline Stream& operator<<(Stream& fs, Stream& (*manip)(Stream&)) 443 | { 444 | fs.flush(); 445 | return manip(fs); 446 | } 447 | 448 | /** 449 | * A convenience macro around gltext::Stream(). Used as follows: 450 | * GLTEXT_STREAM(renderer) << blah blah blah; 451 | * 452 | * This is the preferred interface for streaming text to a 453 | * renderer. 454 | */ 455 | #define GLTEXT_STREAM(renderer) gltext::Stream(renderer).get() 456 | 457 | 458 | /** 459 | * PRIVATE API - for internal use only 460 | * Anonymous namespace containing our exported functions. They are extern "C" 461 | * so we don't mangle the names and they export nicely as shared libraries. 462 | */ 463 | namespace internal 464 | { 465 | /// Gets version information 466 | GLTEXT_FUNC(const char*) GLTextGetVersion(); 467 | 468 | /// Creates a new Font by name. 469 | GLTEXT_FUNC(Font*) GLTextOpenFont(const char* name, int size, int dpi); 470 | 471 | /// Creates a new FontRenderer. 472 | GLTEXT_FUNC(FontRenderer*) GLTextCreateRenderer( 473 | FontRendererType type, 474 | Font* font); 475 | } 476 | 477 | /** 478 | * Gets the version string for GLText. 479 | * 480 | * @return GLText version information 481 | */ 482 | inline const char* GetVersion() 483 | { 484 | return internal::GLTextGetVersion(); 485 | } 486 | 487 | /** 488 | * Creates a new font from the given name, style and point size. 489 | * 490 | * @param name the name of a particular font face. 491 | * @param size the point size of the font, in 1/72nds of an inch. 492 | * @param dpi number of pixels per inch on the display 493 | */ 494 | inline Font* OpenFont(const char* name, int size, int dpi = 72) 495 | { 496 | return internal::GLTextOpenFont(name, size, dpi); 497 | } 498 | 499 | /** 500 | * Creates a new font renderer of the given type. 501 | * 502 | * @param type the type of renderer to create. 503 | * @param font the font to render 504 | */ 505 | inline FontRenderer* CreateRenderer(FontRendererType type, 506 | const FontPtr& font) 507 | { 508 | return internal::GLTextCreateRenderer(type, font.get()); 509 | } 510 | } 511 | 512 | 513 | #endif 514 | -------------------------------------------------------------------------------- /example/arial_10_bitmap.h: -------------------------------------------------------------------------------- 1 | namespace font_10 { 2 | static int imageW = 128; 3 | static int imageH = 60; 4 | static unsigned char image[] = { //gray-scale image 5 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 6 | 0,203,54,0,0,0,54,202,0,0,255,255,252,218,68,0,0,8,164,233,169,26,0,0,255,255,250,81,0,0,0,255,255,255,255,255,0,0,255,0,0,0,0,0,0,81,250,250,81,0,0,0,255,0,0,0,255,0,0,255,0,0,0,93,219,225,85,0,0,255,0,0,0,100,151,0,0,255,255,255,255,255,0,0,255,0,98,254,97,0,255,0,0,255,0,0,84,255,0,0,0,127,220,222,127,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,46,0,0,0,0,0,0,0, 7 | 0,96,162,0,0,0,162,95,0,0,255,0,1,65,217,0,0,135,74,12,146,148,0,0,255,0,81,245,81,0,0,255,0,0,0,0,0,0,255,0,0,0,0,0,81,245,81,81,245,81,0,0,255,0,0,0,255,0,0,255,0,0,0,207,62,64,221,0,0,255,0,0,59,187,5,0,0,255,0,0,0,0,0,0,255,0,173,165,172,0,255,0,0,255,0,6,217,255,0,0,111,152,34,34,153,112,0,0,255,0,0,0,0,0,0,0,132,224,219,190,196,0,0,0,0,0,0,0, 8 | 0,8,236,255,255,255,236,8,0,0,255,0,2,47,233,0,0,213,33,0,18,113,0,0,255,0,0,81,250,0,0,255,0,0,0,0,0,0,255,0,0,0,0,0,250,81,0,0,81,250,0,0,255,0,0,0,255,0,0,255,0,0,0,0,0,2,253,0,0,255,127,29,202,21,0,0,0,255,0,0,0,0,0,0,255,6,227,20,227,5,255,0,0,255,0,116,149,255,0,0,207,25,0,0,27,202,0,0,255,0,0,0,0,0,0,115,140,18,187,218,64,0,0,0,0,0,0,0, 9 | 0,0,138,117,0,117,137,0,0,0,255,255,255,255,118,0,0,245,8,0,0,0,0,0,255,0,0,0,255,0,0,255,255,255,255,255,0,0,255,255,255,0,0,0,255,0,0,255,255,255,0,0,255,255,255,255,255,0,0,255,0,0,0,0,0,0,255,0,0,255,115,227,48,0,0,0,0,255,0,0,0,0,0,0,255,68,152,0,153,67,255,0,0,255,20,224,20,255,0,0,237,6,0,0,8,242,0,0,255,255,250,185,67,0,0,205,42,0,44,90,200,0,0,0,0,0,0,0, 10 | 0,0,33,219,4,218,32,0,0,0,255,0,3,67,137,0,0,211,31,0,5,51,0,0,255,0,0,81,250,0,0,255,0,0,0,0,0,0,255,0,0,0,0,0,250,81,0,0,17,8,0,0,255,0,0,0,255,0,0,255,0,0,0,0,0,0,255,0,0,255,0,114,127,0,0,0,0,255,0,0,0,0,0,0,255,143,52,0,53,142,255,0,0,255,148,116,0,255,0,0,169,27,0,0,41,201,0,0,255,0,5,85,205,0,0,243,10,0,0,11,242,0,0,0,0,0,0,0, 11 | 0,0,0,180,148,179,0,0,0,0,255,0,5,70,232,0,0,133,74,9,125,172,0,0,255,0,81,245,81,0,0,255,0,0,0,0,0,0,255,0,0,0,0,0,81,245,81,63,217,61,0,0,255,0,0,0,255,0,0,255,0,0,0,0,0,0,255,0,0,255,0,0,113,127,0,0,0,255,0,0,0,0,0,0,255,171,0,0,0,171,255,0,0,255,216,6,0,255,0,0,88,149,32,7,154,108,0,0,255,0,1,65,230,0,0,203,42,0,0,3,207,0,0,0,0,0,0,0, 12 | 0,0,0,73,255,73,0,0,0,0,255,255,253,221,90,0,0,4,153,232,178,33,0,0,255,255,250,81,0,0,0,255,255,255,255,255,0,0,255,255,255,255,0,0,0,81,250,248,70,0,0,0,255,0,0,0,255,0,0,255,0,0,0,0,0,0,255,0,0,255,0,0,0,112,127,0,0,255,0,0,0,0,0,0,255,109,0,0,0,110,255,0,0,255,84,0,0,255,0,0,3,87,199,218,122,0,0,0,255,255,253,227,87,0,0,111,139,19,30,152,116,0,0,0,0,0,0,0, 13 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,126,220,220,127,0,0,0,0,0,0,0,0, 14 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 15 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 16 | 255,0,0,1,199,52,0,0,53,201,243,208,56,0,0,0,0,255,0,0,0,0,41,197,241,192,39,0,0,0,0,124,233,128,0,0,0,0,0,100,255,93,0,86,255,92,0,0,0,156,87,0,0,0,87,156,0,0,0,0,0,255,0,0,0,0,0,255,255,255,255,255,255,0,0,139,237,132,255,0,0,255,149,208,55,0,0,55,192,211,62,0,0,65,225,149,255,0,0,58,196,254,159,0,0,0,255,0,0,0,0,0,69,212,218,72,0,0,255,0,0,255,0,0,255,0,0,0, 17 | 255,0,0,97,158,0,0,0,215,88,9,59,218,0,0,0,0,255,0,0,0,0,195,117,20,135,192,0,0,0,1,219,76,222,1,0,0,0,0,163,196,144,0,139,194,156,0,0,0,8,189,31,0,30,189,8,0,0,0,0,0,255,0,0,0,0,0,135,120,0,0,0,0,0,0,236,87,82,255,0,0,255,94,97,176,0,0,180,93,70,200,0,0,208,97,92,255,0,0,182,75,28,0,0,0,0,255,0,0,0,0,0,209,62,82,211,0,0,255,0,0,255,0,0,255,0,0,0, 18 | 255,0,44,193,15,0,0,0,0,0,0,49,220,0,0,0,0,255,0,0,0,0,238,17,0,35,237,0,0,0,62,195,0,196,64,0,0,0,0,226,81,195,0,192,75,220,0,0,0,0,33,177,5,175,33,0,0,0,0,0,0,255,0,0,0,0,0,0,133,121,0,0,0,0,0,73,179,229,255,0,0,255,14,17,240,0,0,240,16,0,0,0,0,245,16,16,255,0,0,236,255,255,234,0,0,0,255,0,0,0,0,0,60,206,115,246,0,0,255,4,0,255,0,0,255,0,0,0, 19 | 255,255,255,224,75,0,0,0,16,126,199,190,48,0,0,0,0,255,0,0,0,0,255,0,0,0,255,0,0,0,158,95,0,96,160,0,0,0,34,221,6,237,4,232,3,220,29,0,0,0,0,74,203,76,0,0,0,0,0,0,101,231,100,0,0,0,0,0,0,131,123,0,0,0,0,0,29,48,237,0,0,255,97,95,213,0,0,205,101,71,196,0,0,212,91,98,255,0,0,176,76,73,165,0,0,0,255,0,0,0,0,0,190,92,94,255,0,0,255,84,81,250,0,0,255,0,0,0, 20 | 255,0,1,61,215,0,0,0,199,119,18,0,0,0,0,0,0,255,0,0,0,0,255,0,0,0,255,0,0,11,228,10,0,10,228,12,0,0,98,158,0,205,83,197,0,157,94,0,0,0,0,23,208,24,0,0,0,0,0,45,198,18,202,44,0,0,0,0,0,0,129,125,0,0,0,71,219,236,111,0,0,255,113,230,73,0,0,52,212,203,49,0,0,72,226,152,255,0,0,52,193,192,44,0,0,255,255,255,0,0,0,0,242,15,17,255,0,0,255,102,237,81,0,0,255,0,0,0, 21 | 255,0,0,73,227,0,0,0,225,87,15,97,213,0,0,0,0,255,0,0,0,0,255,0,0,0,255,0,0,95,150,0,0,0,151,96,0,0,161,94,0,154,186,145,0,93,158,0,0,0,5,179,55,181,6,0,0,0,11,202,38,0,42,203,11,0,0,0,0,0,0,127,127,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,250,81,1,0,0,0,211,92,97,255,0,0,255,0,0,0,0,0,0,0,0,0, 22 | 255,255,255,228,94,0,0,0,64,210,243,200,51,0,0,255,255,255,255,255,0,0,255,0,0,0,255,0,0,192,50,0,0,0,50,192,0,0,224,31,0,102,254,93,0,28,223,0,0,0,152,87,0,87,152,0,0,0,161,94,0,0,0,96,160,0,0,255,255,255,255,255,255,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,81,247,73,0,0,0,70,223,106,255,0,0,255,0,0,0,0,0,255,0,0,0, 23 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 24 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 25 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 26 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 27 | 79,247,81,0,0,255,0,45,205,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,58,200,221,62,0,0,255,0,0,0,0,0,0,0,0,255,0,0,255,0,0,0,135,231,250,81,0,0,0,190,245,0,0,81,242,125,255,0,0,0,55,255,65,0,0,0,105,255,49,0,71,255,104,0,0,153,99,0,99,152,0,0,0,237,80,0,0,0,0,255,255,255,255,255,0,0,67,227,249,225,44,0,0,0,0,255,0,0,222,255,255,255,255,0,0,0,0,0,0, 28 | 2,82,250,0,0,255,49,144,106,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,181,94,94,208,0,0,255,0,0,0,0,0,0,0,0,255,0,0,255,0,0,0,0,0,186,236,0,0,0,253,17,0,0,250,81,82,255,0,0,0,157,165,164,0,0,0,139,201,149,0,165,208,138,0,0,6,191,110,188,5,0,0,0,56,207,0,0,0,0,96,204,28,0,0,0,0,137,101,14,104,183,0,0,0,0,255,0,0,58,187,43,0,0,0,0,0,0,0,0, 29 | 0,0,255,0,0,255,202,227,16,0,0,255,0,0,255,6,0,255,4,0,255,0,0,255,8,0,255,0,0,236,16,16,241,0,0,255,166,223,60,0,0,55,205,161,255,0,0,255,2,0,0,37,217,245,60,0,0,0,255,0,0,0,255,0,5,255,0,0,13,227,14,227,16,0,0,172,89,224,22,234,93,171,0,0,0,51,255,47,0,0,0,0,38,255,51,0,0,0,0,67,213,48,0,0,0,197,16,0,18,222,0,0,0,0,255,0,0,0,7,157,78,0,0,0,0,0,0,0, 30 | 0,0,255,0,0,255,58,210,5,0,0,255,0,0,255,86,56,253,98,82,250,0,0,255,98,82,250,0,0,171,94,96,179,0,0,255,90,95,206,0,0,178,97,93,255,0,0,255,47,0,0,216,178,14,0,0,0,0,255,0,0,0,255,0,0,255,0,0,104,147,0,146,106,0,0,206,46,152,187,164,49,205,0,0,6,191,110,189,5,0,0,0,142,198,153,0,0,0,0,0,44,213,73,0,0,244,5,0,4,248,0,0,0,0,255,0,0,0,0,3,166,70,0,0,0,0,0,0, 31 | 0,0,255,0,0,255,0,100,151,0,0,255,0,0,255,126,233,107,146,243,81,0,0,255,132,237,81,0,0,56,205,197,54,0,0,255,16,17,244,0,0,240,16,17,255,0,0,255,176,0,0,81,251,238,147,0,0,255,255,255,0,0,255,0,0,255,0,0,205,49,0,49,206,0,0,239,12,53,255,70,16,239,0,0,153,97,0,103,149,0,0,9,228,28,229,12,0,0,255,255,255,255,252,0,0,223,26,0,17,228,0,0,95,5,255,0,0,0,0,0,39,219,0,0,0,0,0,0, 32 | 0,0,255,0,0,255,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,99,95,210,0,0,212,93,102,255,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,98,158,0,153,102,0,0,0,0,0,0,0,0,0,183,112,24,132,188,0,0,134,204,255,0,0,190,97,17,107,201,0,0,0,0,0,0, 33 | 0,0,255,0,0,255,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,144,227,70,0,0,72,228,141,255,0,0,0,0,0,0,0,0,0,0,0,0,0,140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,203,52,0,51,204,0,0,0,0,0,0,0,0,0,44,225,246,210,59,0,0,0,47,238,0,0,46,178,236,179,54,0,0,0,0,0,0, 34 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 35 | 0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 36 | 45,179,235,167,41,0,0,0,0,0,0,255,0,0,0,47,180,229,132,21,0,0,21,140,231,196,30,0,0,0,231,25,0,0,0,0,53,179,237,179,53,0,0,55,195,232,155,5,0,0,255,0,0,0,19,138,210,244,231,191,80,0,0,0,218,33,215,37,0,0,0,0,0,255,0,0,0,0,0,63,187,0,81,245,81,0,0,192,64,0,64,192,0,0,41,158,237,207,75,147,149,0,0,117,50,120,0,0,0,89,170,0,0,171,87,0,0,0,255,255,0,0,0,0,0,0,0,0, 37 | 190,74,13,78,186,0,0,0,0,0,0,255,0,0,0,191,70,8,55,157,0,0,122,110,16,97,185,0,0,0,180,76,0,0,0,0,194,46,10,68,202,0,0,195,89,9,87,138,0,0,0,0,0,23,228,133,40,10,23,62,178,142,0,0,145,107,141,111,0,0,0,72,223,255,243,76,0,0,0,0,190,60,250,162,250,0,0,64,192,0,192,64,0,0,195,123,16,57,246,247,24,0,0,90,243,88,0,0,28,217,21,0,0,21,216,25,0,0,0,0,0,0,0,0,0,0,0,0, 38 | 0,0,0,78,236,0,0,255,255,255,255,255,255,0,0,0,0,0,4,231,0,0,195,20,0,10,237,0,0,0,89,169,0,0,0,0,211,68,14,74,208,0,0,42,178,233,134,208,0,0,255,0,0,157,127,93,235,161,216,193,72,0,0,0,255,255,255,255,255,0,0,218,80,255,81,250,0,0,0,0,61,188,250,162,250,0,0,0,192,128,192,0,0,0,201,50,0,146,133,223,153,0,0,154,228,156,0,0,135,117,0,0,0,0,117,131,0,0,0,0,0,0,0,0,0,0,0,0, 39 | 0,13,244,255,98,0,0,127,112,0,0,255,0,0,0,224,84,9,52,167,0,0,245,133,21,93,168,0,0,0,2,213,36,0,0,0,52,248,255,249,51,0,0,168,95,20,131,244,0,0,255,0,0,218,49,225,59,135,255,47,208,89,0,0,9,235,14,235,9,0,0,0,0,255,45,255,0,0,81,245,81,188,143,245,81,0,0,0,64,255,64,0,0,0,40,180,171,144,0,14,45,0,0,0,0,0,0,0,196,56,0,0,0,0,57,194,0,0,0,0,0,0,0,0,0,0,0,0, 40 | 0,0,18,117,202,0,0,0,127,112,0,255,0,0,0,160,188,226,169,38,0,0,220,146,234,177,40,0,0,0,0,67,170,0,0,0,208,69,13,68,208,0,0,233,11,0,17,220,0,0,255,0,0,236,14,231,17,18,255,80,55,211,0,0,255,255,255,255,255,0,0,8,110,255,240,128,0,0,250,162,250,59,189,0,0,0,0,0,0,0,0,0,0,0,0,85,186,196,98,0,0,0,0,0,0,0,0,0,242,12,0,0,0,0,12,241,0,0,0,0,0,0,0,0,0,0,0,0, 41 | 181,108,16,95,221,0,0,0,0,127,112,255,0,0,0,96,152,0,0,0,0,0,141,96,10,94,194,0,0,0,0,0,107,117,0,0,201,71,14,74,196,0,0,159,107,21,98,162,0,0,255,0,0,183,58,158,127,62,255,150,20,238,0,0,0,111,141,107,145,0,0,184,206,255,46,0,0,0,250,162,250,0,186,62,0,0,0,0,0,0,0,0,0,0,0,227,54,54,224,0,0,0,0,0,0,0,0,0,204,40,0,0,0,0,41,203,0,0,0,0,0,0,0,0,0,0,0,0, 42 | 34,171,238,200,54,0,0,0,0,0,127,255,0,0,0,32,255,255,255,255,0,0,14,124,221,191,52,0,0,255,255,255,255,252,0,0,53,177,235,173,48,0,0,34,162,235,173,14,0,0,255,0,0,95,146,16,188,224,127,220,102,177,0,0,0,37,215,33,218,0,0,250,96,255,82,194,0,0,81,245,81,0,57,191,0,0,0,0,0,0,0,0,0,0,0,90,213,221,97,0,0,0,0,0,0,0,0,0,144,103,0,0,0,0,105,143,0,0,0,0,0,0,0,0,0,0,0,0, 43 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,138,98,23,7,42,122,228,48,0,0,0,0,0,0,0,0,0,81,250,255,204,53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,200,9,0,0,9,199,20,0,0,0,0,0,0,0,0,0,0,0,0, 44 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,101,169,232,217,160,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,158,0,0,158,84,0,0,0,0,0,0,0,0,0,0,0,0,0, 45 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 46 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 47 | 255,255,255,255,255,255,0,0,0,33,218,0,0,64,192,0,0,154,36,145,241,138,0,0,255,255,255,255,255,0,0,0,0,255,0,0,0,0,255,255,0,0,255,255,0,0,0,149,249,0,0,251,156,0,0,0,178,0,0,177,0,0,255,0,0,173,0,173,0,0,0,0,64,192,0,0,192,64,0,0,0,0,219,32,0,0,0,0,0,0,255,0,0,0,0,178,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 48 | 0,0,0,0,0,0,0,0,0,106,145,0,0,192,64,0,0,94,231,143,27,156,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,255,0,0,0,0,255,0,0,0,247,25,0,0,36,253,0,0,0,255,0,0,243,0,0,0,0,0,241,0,242,0,0,64,192,192,64,0,0,64,192,192,64,0,0,146,105,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 49 | 0,0,0,0,0,0,0,0,0,179,72,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,255,255,255,255,255,0,0,255,0,0,0,0,255,0,0,6,250,0,0,0,0,255,5,0,0,0,0,0,255,0,0,0,0,0,255,0,255,0,0,255,128,0,0,0,0,0,0,128,255,0,0,73,178,0,0,0,0,0,0,242,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 50 | 0,0,0,0,0,0,0,0,7,235,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,255,0,0,0,0,255,0,0,68,202,0,0,0,0,223,68,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,192,192,64,0,0,64,192,192,64,0,0,9,235,7,0,0,0,0,0,116,188,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 51 | 0,0,0,0,0,0,0,0,69,182,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,255,0,0,0,0,255,0,0,250,58,0,0,0,0,61,250,0,0,0,0,0,0,0,0,255,0,0,0,0,0,0,0,0,0,64,192,0,0,192,64,0,0,0,0,0,183,68,0,0,0,0,0,0,95,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 52 | 0,0,0,0,0,0,0,0,142,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,255,0,0,68,211,0,0,0,0,204,68,0,0,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,110,141,0,0,175,129,26,25,120,203,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 53 | 0,0,0,0,0,0,0,0,215,36,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,255,0,0,5,248,0,0,0,0,250,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,37,215,0,0,26,159,223,225,162,41,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 54 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,0,0,0,0,255,0,0,0,253,36,0,0,26,244,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 55 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,255,255,0,0,0,159,251,0,0,249,146,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 56 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 57 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 58 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 59 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 60 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 61 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 62 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 63 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 64 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 65 | }; 66 | } 67 | -------------------------------------------------------------------------------- /example/arial_10.h: -------------------------------------------------------------------------------- 1 | namespace font_10 { 2 | struct GlyphInfo 3 | { 4 | struct Pix // pixel oriented data 5 | { 6 | int u, v; 7 | int width, height; 8 | int advance; 9 | int offX, offY; 10 | }; 11 | struct Norm // normalized data 12 | { 13 | float u, v; // position in the map in normalized coords 14 | float width, height; 15 | float advance; 16 | float offX, offY; 17 | }; 18 | Pix pix; 19 | Norm norm; 20 | }; 21 | struct FileHeader 22 | { 23 | int texwidth, texheight; 24 | struct Pix 25 | { 26 | int ascent; 27 | int descent; 28 | int linegap; 29 | }; 30 | struct Norm 31 | { 32 | float ascent; 33 | float descent; 34 | float linegap; 35 | }; 36 | Pix pix; 37 | Norm norm; 38 | GlyphInfo glyphs[256]; 39 | }; 40 | static FileHeader font = 41 | { 128, 60, 42 | { 10, -3, 5 }, 43 | { 0.167f, -0.050f, 0.083f }, 44 | { 45 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 46 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 47 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 48 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 49 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 50 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 51 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 52 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 53 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 54 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 55 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 56 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 57 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 58 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 59 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 60 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 61 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 62 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 63 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 64 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 65 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 66 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 67 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 68 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 69 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 70 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 71 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 72 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 73 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 74 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 75 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 76 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 77 | /* */{ { 101, 42, 0, 0, 3, 0, 0 },{0.789f, 0.700f, 0.000f, 0.000f, 0.023f, 0.000f, 0.000f} }, 78 | /*!*/{ { 50, 31, 1, 7, 3, 1, -7 },{0.391f, 0.517f, 0.008f, 0.117f, 0.023f, 0.008f, -0.117f} }, 79 | /*"*/{ { 65, 42, 3, 3, 4, 0, -7 },{0.508f, 0.700f, 0.023f, 0.050f, 0.031f, 0.000f, -0.117f} }, 80 | /*#*/{ { 64, 31, 5, 7, 6, 0, -7 },{0.500f, 0.517f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 81 | /*$*/{ { 71, 31, 5, 8, 6, 0, -7 },{0.555f, 0.517f, 0.039f, 0.133f, 0.047f, 0.000f, -0.117f} }, 82 | /*%*/{ { 78, 31, 7, 7, 9, 1, -7 },{0.609f, 0.517f, 0.055f, 0.117f, 0.070f, 0.008f, -0.117f} }, 83 | /*&*/{ { 94, 31, 7, 7, 7, 0, -7 },{0.734f, 0.517f, 0.055f, 0.117f, 0.055f, 0.000f, -0.117f} }, 84 | /*'*/{ { 59, 42, 1, 3, 2, 0, -7 },{0.461f, 0.700f, 0.008f, 0.050f, 0.016f, 0.000f, -0.117f} }, 85 | /*(*/{ { 108, 31, 3, 9, 3, 0, -7 },{0.844f, 0.517f, 0.023f, 0.150f, 0.023f, 0.000f, -0.117f} }, 86 | /*)*/{ { 113, 31, 3, 9, 3, 0, -7 },{0.883f, 0.517f, 0.023f, 0.150f, 0.023f, 0.000f, -0.117f} }, 87 | /***/{ { 103, 31, 3, 3, 4, 0, -7 },{0.805f, 0.517f, 0.023f, 0.050f, 0.031f, 0.000f, -0.117f} }, 88 | /*+*/{ { 31, 42, 5, 5, 6, 0, -6 },{0.242f, 0.700f, 0.039f, 0.083f, 0.047f, 0.000f, -0.100f} }, 89 | /*,*/{ { 95, 42, 1, 2, 3, 1, -1 },{0.742f, 0.700f, 0.008f, 0.033f, 0.023f, 0.008f, -0.017f} }, 90 | /*-*/{ { 118, 31, 2, 1, 3, 0, -3 },{0.922f, 0.517f, 0.016f, 0.017f, 0.023f, 0.000f, -0.050f} }, 91 | /*.*/{ { 98, 42, 1, 1, 3, 1, -1 },{0.766f, 0.700f, 0.008f, 0.017f, 0.023f, 0.008f, -0.017f} }, 92 | /*/*/{ { 82, 42, 3, 7, 3, 0, -7 },{0.641f, 0.700f, 0.023f, 0.117f, 0.023f, 0.000f, -0.117f} }, 93 | /*0*/{ { 105, 22, 5, 7, 6, 0, -7 },{0.820f, 0.367f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 94 | /*1*/{ { 112, 22, 3, 7, 6, 1, -7 },{0.875f, 0.367f, 0.023f, 0.117f, 0.047f, 0.008f, -0.117f} }, 95 | /*2*/{ { 117, 22, 5, 7, 6, 0, -7 },{0.914f, 0.367f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 96 | /*3*/{ { 0, 31, 5, 7, 6, 0, -7 },{0.000f, 0.517f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 97 | /*4*/{ { 7, 31, 6, 7, 6, 0, -7 },{0.055f, 0.517f, 0.047f, 0.117f, 0.047f, 0.000f, -0.117f} }, 98 | /*5*/{ { 15, 31, 5, 7, 6, 0, -7 },{0.117f, 0.517f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 99 | /*6*/{ { 22, 31, 5, 7, 6, 0, -7 },{0.172f, 0.517f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 100 | /*7*/{ { 29, 31, 5, 7, 6, 0, -7 },{0.227f, 0.517f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 101 | /*8*/{ { 36, 31, 5, 7, 6, 0, -7 },{0.281f, 0.517f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 102 | /*9*/{ { 43, 31, 5, 7, 6, 0, -7 },{0.336f, 0.517f, 0.039f, 0.117f, 0.047f, 0.000f, -0.117f} }, 103 | /*:*/{ { 62, 42, 1, 5, 3, 1, -5 },{0.484f, 0.700f, 0.008f, 0.083f, 0.023f, 0.008f, -0.083f} }, 104 | /*;*/{ { 56, 42, 1, 6, 3, 1, -5 },{0.438f, 0.700f, 0.008f, 0.100f, 0.023f, 0.008f, -0.083f} }, 105 | /*<*/{ { 70, 42, 4, 5, 6, 1, -6 },{0.547f, 0.700f, 0.031f, 0.083f, 0.047f, 0.008f, -0.100f} }, 106 | /*=*/{ { 24, 42, 5, 3, 6, 0, -5 },{0.188f, 0.700f, 0.039f, 0.050f, 0.047f, 0.000f, -0.083f} }, 107 | /*>*/{ { 76, 42, 4, 5, 6, 1, -6 },{0.594f, 0.700f, 0.031f, 0.083f, 0.047f, 0.008f, -0.100f} }, 108 | /*?*/{ { 87, 42, 6, 7, 6, 0, -7 },{0.680f, 0.700f, 0.047f, 0.117f, 0.047f, 0.000f, -0.117f} }, 109 | /*@*/{ { 53, 31, 9, 9, 10, 1, -7 },{0.414f, 0.517f, 0.070f, 0.150f, 0.078f, 0.008f, -0.117f} }, 110 | /*A*/{ { 1, 1, 7, 7, 7, 0, -7 },{0.008f, 0.017f, 0.055f, 0.117f, 0.055f, 0.000f, -0.117f} }, 111 | /*B*/{ { 10, 1, 5, 7, 7, 1, -7 },{0.078f, 0.017f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 112 | /*C*/{ { 17, 1, 5, 7, 7, 1, -7 },{0.133f, 0.017f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 113 | /*D*/{ { 24, 1, 5, 7, 7, 1, -7 },{0.188f, 0.017f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 114 | /*E*/{ { 31, 1, 5, 7, 7, 1, -7 },{0.242f, 0.017f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 115 | /*F*/{ { 38, 1, 4, 7, 6, 1, -7 },{0.297f, 0.017f, 0.031f, 0.117f, 0.047f, 0.008f, -0.117f} }, 116 | /*G*/{ { 44, 1, 6, 7, 8, 1, -7 },{0.344f, 0.017f, 0.047f, 0.117f, 0.063f, 0.008f, -0.117f} }, 117 | /*H*/{ { 52, 1, 5, 7, 7, 1, -7 },{0.406f, 0.017f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 118 | /*I*/{ { 59, 1, 1, 7, 3, 1, -7 },{0.461f, 0.017f, 0.008f, 0.117f, 0.023f, 0.008f, -0.117f} }, 119 | /*J*/{ { 62, 1, 5, 7, 5, -1, -7 },{0.484f, 0.017f, 0.039f, 0.117f, 0.039f, -0.008f, -0.117f} }, 120 | /*K*/{ { 69, 1, 6, 7, 7, 1, -7 },{0.539f, 0.017f, 0.047f, 0.117f, 0.055f, 0.008f, -0.117f} }, 121 | /*L*/{ { 77, 1, 5, 7, 6, 1, -7 },{0.602f, 0.017f, 0.039f, 0.117f, 0.047f, 0.008f, -0.117f} }, 122 | /*M*/{ { 84, 1, 7, 7, 9, 1, -7 },{0.656f, 0.017f, 0.055f, 0.117f, 0.070f, 0.008f, -0.117f} }, 123 | /*N*/{ { 93, 1, 5, 7, 7, 1, -7 },{0.727f, 0.017f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 124 | /*O*/{ { 100, 1, 6, 7, 8, 1, -7 },{0.781f, 0.017f, 0.047f, 0.117f, 0.063f, 0.008f, -0.117f} }, 125 | /*P*/{ { 108, 1, 5, 7, 7, 1, -7 },{0.844f, 0.017f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 126 | /*Q*/{ { 115, 1, 6, 8, 8, 1, -7 },{0.898f, 0.017f, 0.047f, 0.133f, 0.063f, 0.008f, -0.117f} }, 127 | /*R*/{ { 0, 11, 6, 7, 7, 1, -7 },{0.000f, 0.183f, 0.047f, 0.117f, 0.055f, 0.008f, -0.117f} }, 128 | /*S*/{ { 8, 11, 5, 7, 7, 1, -7 },{0.063f, 0.183f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 129 | /*T*/{ { 15, 11, 5, 7, 7, 1, -7 },{0.117f, 0.183f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 130 | /*U*/{ { 22, 11, 5, 7, 7, 1, -7 },{0.172f, 0.183f, 0.039f, 0.117f, 0.055f, 0.008f, -0.117f} }, 131 | /*V*/{ { 29, 11, 7, 7, 7, 0, -7 },{0.227f, 0.183f, 0.055f, 0.117f, 0.055f, 0.000f, -0.117f} }, 132 | /*W*/{ { 38, 11, 9, 7, 9, 0, -7 },{0.297f, 0.183f, 0.070f, 0.117f, 0.070f, 0.000f, -0.117f} }, 133 | /*X*/{ { 49, 11, 7, 7, 7, 0, -7 },{0.383f, 0.183f, 0.055f, 0.117f, 0.055f, 0.000f, -0.117f} }, 134 | /*Y*/{ { 58, 11, 7, 7, 7, 0, -7 },{0.453f, 0.183f, 0.055f, 0.117f, 0.055f, 0.000f, -0.117f} }, 135 | /*Z*/{ { 67, 11, 6, 7, 6, 0, -7 },{0.523f, 0.183f, 0.047f, 0.117f, 0.047f, 0.000f, -0.117f} }, 136 | /*[*/{ { 38, 42, 2, 9, 3, 1, -7 },{0.297f, 0.700f, 0.016f, 0.150f, 0.023f, 0.008f, -0.117f} }, 137 | /*\*/{ { 8, 42, 3, 7, 3, 0, -7 },{0.063f, 0.700f, 0.023f, 0.117f, 0.023f, 0.000f, -0.117f} }, 138 | /*]*/{ { 42, 42, 2, 9, 3, 0, -7 },{0.328f, 0.700f, 0.016f, 0.150f, 0.023f, 0.000f, -0.117f} }, 139 | /*^*/{ { 87, 31, 5, 4, 5, 0, -7 },{0.680f, 0.517f, 0.039f, 0.067f, 0.039f, 0.000f, -0.117f} }, 140 | /*_*/{ { 0, 42, 6, 1, 6, 0, 1 },{0.000f, 0.700f, 0.047f, 0.017f, 0.047f, 0.000f, 0.017f} }, 141 | /*`*/{ { 13, 42, 2, 2, 3, 0, -7 },{0.102f, 0.700f, 0.016f, 0.033f, 0.023f, 0.000f, -0.117f} }, 142 | /*a*/{ { 75, 11, 4, 5, 6, 1, -5 },{0.586f, 0.183f, 0.031f, 0.083f, 0.047f, 0.008f, -0.083f} }, 143 | /*b*/{ { 81, 11, 4, 7, 6, 1, -7 },{0.633f, 0.183f, 0.031f, 0.117f, 0.047f, 0.008f, -0.117f} }, 144 | /*c*/{ { 87, 11, 4, 5, 6, 1, -5 },{0.680f, 0.183f, 0.031f, 0.083f, 0.047f, 0.008f, -0.083f} }, 145 | /*d*/{ { 93, 11, 4, 7, 6, 1, -7 },{0.727f, 0.183f, 0.031f, 0.117f, 0.047f, 0.008f, -0.117f} }, 146 | /*e*/{ { 99, 11, 4, 5, 6, 1, -5 },{0.773f, 0.183f, 0.031f, 0.083f, 0.047f, 0.008f, -0.083f} }, 147 | /*f*/{ { 105, 11, 4, 7, 3, 0, -7 },{0.820f, 0.183f, 0.031f, 0.117f, 0.023f, 0.000f, -0.117f} }, 148 | /*g*/{ { 111, 11, 5, 7, 6, 0, -5 },{0.867f, 0.183f, 0.039f, 0.117f, 0.047f, 0.000f, -0.083f} }, 149 | /*h*/{ { 118, 11, 4, 7, 6, 1, -7 },{0.922f, 0.183f, 0.031f, 0.117f, 0.047f, 0.008f, -0.117f} }, 150 | /*i*/{ { 124, 11, 1, 7, 3, 1, -7 },{0.969f, 0.183f, 0.008f, 0.117f, 0.023f, 0.008f, -0.117f} }, 151 | /*j*/{ { 0, 22, 3, 9, 3, -1, -7 },{0.000f, 0.367f, 0.023f, 0.150f, 0.023f, -0.008f, -0.117f} }, 152 | /*k*/{ { 5, 22, 4, 7, 4, 0, -7 },{0.039f, 0.367f, 0.031f, 0.117f, 0.031f, 0.000f, -0.117f} }, 153 | /*l*/{ { 11, 22, 1, 7, 3, 1, -7 },{0.086f, 0.367f, 0.008f, 0.117f, 0.023f, 0.008f, -0.117f} }, 154 | /*m*/{ { 14, 22, 7, 5, 9, 1, -5 },{0.109f, 0.367f, 0.055f, 0.083f, 0.070f, 0.008f, -0.083f} }, 155 | /*n*/{ { 23, 22, 4, 5, 6, 1, -5 },{0.180f, 0.367f, 0.031f, 0.083f, 0.047f, 0.008f, -0.083f} }, 156 | /*o*/{ { 29, 22, 4, 5, 6, 1, -5 },{0.227f, 0.367f, 0.031f, 0.083f, 0.047f, 0.008f, -0.083f} }, 157 | /*p*/{ { 35, 22, 4, 7, 6, 1, -5 },{0.273f, 0.367f, 0.031f, 0.117f, 0.047f, 0.008f, -0.083f} }, 158 | /*q*/{ { 41, 22, 4, 7, 6, 1, -5 },{0.320f, 0.367f, 0.031f, 0.117f, 0.047f, 0.008f, -0.083f} }, 159 | /*r*/{ { 47, 22, 2, 5, 3, 1, -5 },{0.367f, 0.367f, 0.016f, 0.083f, 0.023f, 0.008f, -0.083f} }, 160 | /*s*/{ { 51, 22, 4, 5, 4, 0, -5 },{0.398f, 0.367f, 0.031f, 0.083f, 0.031f, 0.000f, -0.083f} }, 161 | /*t*/{ { 57, 22, 3, 7, 3, 0, -7 },{0.445f, 0.367f, 0.023f, 0.117f, 0.023f, 0.000f, -0.117f} }, 162 | /*u*/{ { 62, 22, 4, 5, 6, 1, -5 },{0.484f, 0.367f, 0.031f, 0.083f, 0.047f, 0.008f, -0.083f} }, 163 | /*v*/{ { 68, 22, 5, 5, 5, 0, -5 },{0.531f, 0.367f, 0.039f, 0.083f, 0.039f, 0.000f, -0.083f} }, 164 | /*w*/{ { 75, 22, 7, 5, 7, 0, -5 },{0.586f, 0.367f, 0.055f, 0.083f, 0.055f, 0.000f, -0.083f} }, 165 | /*x*/{ { 84, 22, 5, 5, 5, 0, -5 },{0.656f, 0.367f, 0.039f, 0.083f, 0.039f, 0.000f, -0.083f} }, 166 | /*y*/{ { 91, 22, 5, 7, 5, 0, -5 },{0.711f, 0.367f, 0.039f, 0.117f, 0.039f, 0.000f, -0.083f} }, 167 | /*z*/{ { 98, 22, 5, 5, 5, 0, -5 },{0.766f, 0.367f, 0.039f, 0.083f, 0.039f, 0.000f, -0.083f} }, 168 | /*{*/{ { 46, 42, 3, 9, 3, 0, -7 },{0.359f, 0.700f, 0.023f, 0.150f, 0.023f, 0.000f, -0.117f} }, 169 | /*|*/{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 170 | /*}*/{ { 51, 42, 3, 9, 3, 0, -7 },{0.398f, 0.700f, 0.023f, 0.150f, 0.023f, 0.000f, -0.117f} }, 171 | /*~*/{ { 17, 42, 5, 3, 6, 0, -5 },{0.133f, 0.700f, 0.039f, 0.050f, 0.047f, 0.000f, -0.083f} }, 172 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 173 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 174 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 175 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 176 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 177 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 178 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 179 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 180 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 181 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 182 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 183 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 184 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 185 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 186 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 187 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 188 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 189 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 190 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 191 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 192 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 193 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 194 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 195 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 196 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 197 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 198 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 199 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 200 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 201 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 202 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 203 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 204 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 205 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 206 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 207 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 208 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 209 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 210 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 211 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 212 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 213 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 214 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 215 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 216 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 217 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 218 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 219 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 220 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 221 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 222 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 223 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 224 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 225 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 226 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 227 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 228 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 229 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 230 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 231 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 232 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 233 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 234 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 235 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 236 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 237 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 238 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 239 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 240 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 241 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 242 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 243 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 244 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 245 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 246 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 247 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 248 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 249 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 250 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 251 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 252 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 253 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 254 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 255 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 256 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 257 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 258 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 259 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 260 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 261 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 262 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 263 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 264 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 265 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 266 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 267 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 268 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 269 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 270 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 271 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 272 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 273 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 274 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 275 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 276 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 277 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 278 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 279 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 280 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 281 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 282 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 283 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 284 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 285 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 286 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 287 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 288 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 289 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 290 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 291 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 292 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 293 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 294 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 295 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 296 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 297 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 298 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 299 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 300 | /* */{ { 0, 0, 0, 0, 0, 0, 0 },{0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f, 0.000f} }, 301 | } }; 302 | } 303 | -------------------------------------------------------------------------------- /OpenGLText.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | developed by Tristan Lorach - Copyright (c) 2012 NVIDIA Corporation. All rights reserved. 3 | 4 | TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED 5 | *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS 6 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT,IMPLIED WARRANTIES OF 7 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA 8 | OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, SPECIAL, INCIDENTAL, INDIRECT, OR 9 | CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS 10 | OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY 11 | OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, 12 | EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 13 | 14 | Please direct any questions to tlorach@nvidia.com (Tristan Lorach) 15 | =================================================================================== 16 | Example on how to use it. 17 | init time: 18 | OpenGLText oglText; 19 | ... 20 | if(!oglText.init(font_name, canvas_width, canvas_height)) 21 | return false; 22 | 23 | render time: 24 | oglText.beginString(); 25 | float bbStr[2]; 26 | char *tmpStr = "Hello world"; 27 | oglText.stringSize(tmpStr, bbStr); 28 | oglText.drawString(posX - bbStr[0]*0.5, posY - bbStr[1], tmpStr, 0,0xF0F0F0F0); 29 | ... 30 | oglText.endString(); // will render the whole at once 31 | */ 32 | //#define USE_QUADS 33 | #define USE_INSTANCED_ARRAYS 34 | #define NV_REPORT_COMPILE_ERRORS 35 | #define USE_PSEUDO_INSTANCING 36 | #ifdef USE_QUADS 37 | # define TOPOLOGY_PRIM GL_QUADS 38 | # define PRIMNUMBER 4 39 | #else 40 | # define TOPOLOGY_PRIM GL_TRIANGLES 41 | # define PRIMNUMBER 6 42 | #endif 43 | #ifdef USE_INSTANCED_ARRAYS 44 | # define USE_FONT_METRIC_AS_TBO 45 | #endif 46 | #ifdef USE_PSEUDO_INSTANCING 47 | # define USE_INSTANCED_ARRAYS 48 | # define USE_FONT_METRIC_AS_TBO 49 | #endif 50 | 51 | #pragma warning(disable:4244) // dble to float conversion warning 52 | 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | #ifdef WIN32 59 | #include 60 | #define MKDIR(file) _mkdir((file)) 61 | #else 62 | #include 63 | #define MKDIR(file) mkdir((file),0777) 64 | #endif 65 | #include 66 | #include 67 | 68 | #include 69 | 70 | #if defined(__APPLE__) 71 | #include 72 | #else 73 | #include 74 | #endif 75 | 76 | #include "OpenGLText.h" 77 | #include "tga.h" 78 | #ifndef M_PI 79 | #define M_PI 3.14159265358979323846 80 | #endif 81 | 82 | /////////////////////////////////////////////////////////////////////////////////////// 83 | // 84 | // 85 | #ifdef USE_INSTANCED_ARRAYS 86 | char* OpenGLText::cWidgetVSSource2 = { 87 | "#version 140\n\ 88 | uniform vec4 canvas; \n" 89 | #ifdef USE_FONT_METRIC_AS_TBO 90 | "uniform samplerBuffer glyphTexOffset;\n" 91 | #else 92 | "in vec4 TexCoord;\n" 93 | #endif 94 | #ifndef USE_PSEUDO_INSTANCING 95 | "in vec4 Position;\n" 96 | "in int Glyph;\n" 97 | #else 98 | "uniform samplerBuffer quads;\n" 99 | #endif 100 | "out vec2 vsTC;\n\ 101 | \n\ 102 | void main()\n\ 103 | {\n" 104 | #ifdef USE_PSEUDO_INSTANCING 105 | #ifdef USE_QUADS 106 | "int i = gl_VertexID / 4;\n" 107 | #else 108 | "int i = gl_VertexID / 6;\n" 109 | #endif 110 | "vec4 Position = texelFetch(quads, i*2);\n" 111 | "int Glyph = int(texelFetch(quads, i*2+1).x);\n" 112 | #endif 113 | #ifdef USE_QUADS 114 | "int id = gl_VertexID & 3;\n" 115 | #else 116 | "int id = gl_VertexID % 6;\n" 117 | #endif 118 | "float x = Position.x;\n\ 119 | float y = Position.y;\n\ 120 | float w = Position.z;\n\ 121 | float h = Position.w;\n\ 122 | vec4 p = vec4(x,y,0,1);\n" 123 | #ifdef USE_QUADS 124 | "if((id) == 1) { p.x += w; }\n" 125 | "else if((id) == 2) { p.x += w; p.y += h; }\n" 126 | "else if((id) == 3) { p.y += h; }\n" 127 | #else 128 | "switch(id) {\n\ 129 | case 0: break;\n\ 130 | case 3:\n\ 131 | case 1: p.x += w; break;\n\ 132 | case 5:\n\ 133 | case 2: p.y += h; break;\n\ 134 | case 4: p.x += w; p.y += h; break; \n\ 135 | }\n" 136 | #endif 137 | #ifdef USE_FONT_METRIC_AS_TBO 138 | "int g = int(Glyph);\n\ 139 | vec4 ginfo = texelFetch(glyphTexOffset, g);\n\ 140 | x = ginfo.x;\n\ 141 | y = ginfo.y;\n\ 142 | w = ginfo.z;\n\ 143 | h = ginfo.w;\n" 144 | #else 145 | "x = TexCoord.x;\n\ 146 | y = TexCoord.y;\n\ 147 | w = TexCoord.z;\n\ 148 | h = TexCoord.w;\n" 149 | #endif 150 | "vec2 tc = vec2(x,y);\n" 151 | #ifdef USE_QUADS 152 | "if((id) == 1) { tc.x += w; }\n" 153 | "else if((id) == 2) { tc.x += w; tc.y += h; }\n" 154 | "else if((id) == 3) { tc.y += h; }\n" 155 | #else 156 | "switch(id) {\n\ 157 | case 0: break;\n\ 158 | case 3:\n\ 159 | case 1: tc.x += w; break;\n\ 160 | case 5:\n\ 161 | case 2: tc.y += h; break;\n\ 162 | case 4: tc.x += w; tc.y += h; break; \n\ 163 | }\n" 164 | #endif 165 | "gl_Position = vec4( ((p.x / canvas.x)*canvas.z*2.0 - 1.0), \n\ 166 | ((p.y / canvas.y)*2.0 - 1.0), 0, 1.0); \n\ 167 | vsTC = tc; \n\ 168 | }\n\ 169 | "}; 170 | 171 | char* OpenGLText::cWidgetFSSource2 = { 172 | "#version 140\n\ 173 | uniform vec4 color; \n\ 174 | uniform sampler2D fontTex;\n\ 175 | in vec2 vsTC;\n\ 176 | out vec4 fragColor;\n\ 177 | \n\ 178 | void main()\n\ 179 | {\n\ 180 | float a = (texture2D( fontTex, vsTC.xy ).x); \n\ 181 | fragColor.rgb = color.rgb; \n\ 182 | fragColor.a = color.a * a;\n\ 183 | }\n\ 184 | "}; 185 | #else 186 | char* OpenGLText::cWidgetVSSource2 = { 187 | "#version 140\n\ 188 | uniform vec4 canvas; \n\ 189 | \n\ 190 | in vec4 Position;\n\ 191 | in vec4 TexCoord;\n\ 192 | out vec2 vsTC;\n\ 193 | \n\ 194 | void main()\n\ 195 | {\n\ 196 | gl_Position = vec4( (((Position.x) / canvas.x)*canvas.z*2.0 - 1.0), \n\ 197 | (((Position.y) / canvas.y)*2.0 - 1.0), 0, 1.0); \n\ 198 | vsTC = TexCoord.xy; \n\ 199 | }\n\ 200 | "}; 201 | 202 | char* OpenGLText::cWidgetFSSource2 = { 203 | "#version 140\n\ 204 | uniform vec4 color; \n\ 205 | uniform sampler2D fontTex;\n\ 206 | in vec2 vsTC;\n\ 207 | out vec4 fragColor;\n\ 208 | \n\ 209 | void main()\n\ 210 | {\n\ 211 | float distance = (texture2D( fontTex, vsTC.xy ).x); \n\ 212 | fragColor.rgb = color.rgb; \n\ 213 | fragColor.a = color.a * distance;\n\ 214 | }\n\ 215 | "}; 216 | #endif 217 | 218 | /////////////////////////////////////////////////////////////////////////////////////// 219 | // Backup only the states that we really need to setup 220 | // the rendering. We might want to back them up once 221 | // 222 | struct TextBackupState 223 | { 224 | struct vtxAttribData { 225 | GLvoid* ptr; 226 | #ifdef USE_INSTANCED_ARRAYS 227 | int divisor; 228 | #endif 229 | int enabled; 230 | int size; 231 | int type; 232 | int normalized; 233 | int stride; 234 | int bufferBinding; 235 | }; 236 | TextBackupState() { valid = false; } 237 | ~TextBackupState() { if(valid) { 238 | free(attribs); 239 | } } 240 | void backup() 241 | { 242 | glGetIntegerv(GL_POLYGON_MODE, (GLint*)mode); 243 | cull = glIsEnabled(GL_CULL_FACE); 244 | //glGetIntegerv(GL_CULL_FACE_MODE, (GLint*)&); 245 | stenciltest = glIsEnabled(GL_STENCIL_TEST); 246 | glGetIntegerv(GL_STENCIL_VALUE_MASK, (GLint*)&stencilmask); 247 | depthtest = glIsEnabled(GL_DEPTH_TEST); 248 | glGetIntegerv(GL_DEPTH_WRITEMASK, (GLint*)&depthmask); 249 | blend = glIsEnabled(GL_BLEND); 250 | glGetIntegerv(GL_BLEND_SRC, (GLint*)&sfactor); 251 | glGetIntegerv(GL_BLEND_DST, (GLint*)&dfactor); 252 | glGetIntegerv(GL_COLOR_WRITEMASK, (GLint*)&red); 253 | primrestart = glIsEnabled(GL_PRIMITIVE_RESTART); 254 | glGetIntegerv(GL_PRIMITIVE_RESTART_INDEX, (GLint*)&primrestartid); 255 | glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVtxAttribs); 256 | attribs = (vtxAttribData*)malloc(sizeof(vtxAttribData)*maxVtxAttribs); 257 | for(int i=0; i 0)&&(infoLog[0] != '\0')) 431 | fprintf( stderr, "Link failed:\n%s\n", infoLog); 432 | delete [] infoLog; 433 | #endif 434 | 435 | // Test linker result. 436 | GLint linkSucceed = GL_FALSE; 437 | glGetProgramiv(program, GL_LINK_STATUS, &linkSucceed); 438 | 439 | if (linkSucceed == GL_FALSE) 440 | { 441 | glDeleteProgram(program); 442 | return 0; 443 | } 444 | 445 | return program; 446 | } 447 | 448 | /////////////////////////////////////////////////////////////////////////////////////// 449 | // 450 | // 451 | void OpenGLText::changeCanvas(int w, int h) 452 | { 453 | m_canvas.w = w; 454 | m_canvas.h = h; 455 | m_canvas.ratio = ((float)m_canvas.winh*w)/((float)m_canvas.winw*h); 456 | } 457 | /////////////////////////////////////////////////////////////////////////////////////// 458 | // 459 | // 460 | void OpenGLText::changeSize(int w, int h) 461 | { 462 | m_canvas.winw = w; 463 | m_canvas.winh = h; 464 | m_canvas.ratio = ((float)h*m_canvas.w)/((float)w*m_canvas.h); 465 | } 466 | 467 | /////////////////////////////////////////////////////////////////////////////////////// 468 | // 469 | // 470 | bool OpenGLText::init(unsigned char *imageData, FileHeader *glyphInfos_, int w, int h) 471 | { 472 | if(glyphInfos && allocated) 473 | delete glyphInfos; 474 | glyphInfos = glyphInfos_; 475 | allocated = false; 476 | 477 | if(m_fontTex == 0) 478 | glGenTextures( 1, &m_fontTex ); 479 | GLenum extFmt = GL_RED; 480 | glTextureImage2DEXT(m_fontTex, GL_TEXTURE_2D, 0, extFmt, glyphInfos->texwidth, glyphInfos->texheight, 0, extFmt, GL_UNSIGNED_BYTE, imageData); 481 | glTextureParameterf(m_fontTex, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 482 | glTextureParameterf(m_fontTex, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 483 | glTextureParameterf(m_fontTex, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 484 | glTextureParameterf(m_fontTex, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 485 | GLenum err = glGetError(); 486 | return init(w,h); 487 | } 488 | /////////////////////////////////////////////////////////////////////////////////////// 489 | // 490 | // 491 | bool OpenGLText::init(const char * fontName, int w, int h) 492 | { 493 | // 494 | // Load the Font if possible 495 | // 496 | if(fontName) 497 | { 498 | char fname[200]; 499 | sprintf(fname, "%s.tga", fontName); 500 | TGA* fontTGA = new TGA; 501 | TGA::TGAError err = fontTGA->load(fname); 502 | if(err != TGA::TGA_NO_ERROR) 503 | return false; 504 | sprintf(fname, "%s.bin", fontName); 505 | FILE *fd = fopen(fname, "rb"); 506 | if(fd) 507 | { 508 | if(glyphInfos && allocated) 509 | delete glyphInfos; 510 | glyphInfos = new FileHeader; 511 | allocated = true; 512 | int r = (int)fread(glyphInfos, 1, sizeof(FileHeader), fd); 513 | fclose(fd); 514 | // Change the shaders to use for this case 515 | 516 | int u = fontTGA->m_nImageWidth; 517 | int h = fontTGA->m_nImageHeight; 518 | 519 | if(m_fontTex == 0) 520 | glGenTextures( 1, &m_fontTex ); 521 | GLenum extFmt; 522 | switch(fontTGA->m_texFormat) 523 | { 524 | case TGA::RGB: 525 | extFmt = GL_RGB; 526 | break; 527 | case TGA::RGBA: 528 | extFmt = GL_RGBA; 529 | break; 530 | case TGA::ALPHA: 531 | extFmt = GL_LUMINANCE; 532 | break; 533 | } 534 | glTextureImage2DEXT(m_fontTex, GL_TEXTURE_2D, 0, extFmt, u, h, 0, extFmt, GL_UNSIGNED_BYTE, fontTGA->m_nImageData); 535 | glTextureParameterf(m_fontTex, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 536 | glTextureParameterf(m_fontTex, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 537 | glTextureParameterf(m_fontTex, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 538 | glTextureParameterf(m_fontTex, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 539 | GLenum err = glGetError(); 540 | } 541 | delete fontTGA; 542 | } 543 | return init(w,h); 544 | } 545 | bool OpenGLText::init(int w, int h) 546 | { 547 | m_canvas.w = w; 548 | m_canvas.h = h; 549 | m_canvas.ratio = 1.0; 550 | if (m_widgetProgram == 0) 551 | { 552 | m_vShader = CompileGLSLShader( GL_VERTEX_SHADER, cWidgetVSSource2); 553 | if (!m_vShader) 554 | fprintf(stderr, "Vertex shader compile failed\n"); 555 | m_fShader = CompileGLSLShader( GL_FRAGMENT_SHADER, cWidgetFSSource2); 556 | if (!m_fShader) 557 | fprintf(stderr, "Fragment shader compile failed\n"); 558 | 559 | //CHECKGLERRORS(); 560 | 561 | m_widgetProgram = LinkGLSLProgram( m_vShader, m_fShader ); 562 | //CHECKGLERRORS(); 563 | 564 | GLint fontTexLoc = glGetUniformLocation( m_widgetProgram, "fontTex"); 565 | m_canvasVar = glGetUniformLocation( m_widgetProgram, "canvas" ); 566 | m_color = glGetUniformLocation( m_widgetProgram, "color" ); 567 | 568 | glProgramUniform1i(m_widgetProgram, fontTexLoc, 0); //Texture unit 0 is for font Tex. 569 | 570 | glGenBuffers(1, &m_vbo); 571 | #ifdef USE_FONT_METRIC_AS_TBO 572 | // Upload the font metric in a TBO 573 | float *tcs = new float[256*4]; 574 | for(int i=0; i<256; i++) 575 | { 576 | tcs[(4*i)+0] = glyphInfos->glyphs[i].norm.u; 577 | tcs[(4*i)+1] = glyphInfos->glyphs[i].norm.v; 578 | tcs[(4*i)+2] = glyphInfos->glyphs[i].norm.width; 579 | tcs[(4*i)+3] = glyphInfos->glyphs[i].norm.height; 580 | } 581 | GLenum err = glGetError(); 582 | m_locGlyphTexOffset = glGetUniformLocation( m_widgetProgram, "glyphTexOffset" ); 583 | glProgramUniform1i(m_widgetProgram, m_locGlyphTexOffset, 2); 584 | err = glGetError(); 585 | glGenBuffers( 1, &m_boGlyphTexOffset); 586 | glGenTextures( 1, &m_texGlyphTexOffset); 587 | glBindBuffer(GL_TEXTURE_BUFFER, m_boGlyphTexOffset); 588 | glBufferData(GL_TEXTURE_BUFFER, 256*4*sizeof(float), tcs, GL_STATIC_DRAW); 589 | delete [] tcs; 590 | #else 591 | locTc = glGetAttribLocation( m_widgetProgram, "TexCoord" ); 592 | #endif 593 | #ifdef USE_PSEUDO_INSTANCING 594 | // 595 | // In this case, send Quad attributes as TBO 596 | // 597 | m_locQuads = glGetUniformLocation( m_widgetProgram, "quads" ); 598 | glGenTextures( 1, &m_texQuads ); 599 | glProgramUniform1i(m_widgetProgram, m_locQuads, 1); 600 | #else 601 | #ifdef USE_INSTANCED_ARRAYS 602 | locGlyph = glGetAttribLocation( m_widgetProgram, "Glyph" ); 603 | #endif 604 | locPos = glGetAttribLocation( m_widgetProgram, "Position" ); 605 | #endif 606 | } 607 | return true; 608 | } 609 | 610 | /////////////////////////////////////////////////////////////////////////////////////// 611 | // 612 | // 613 | void OpenGLText::pushVertex( Vertex* v ) 614 | { 615 | m_vertices.push_back( *v ); 616 | } 617 | 618 | /////////////////////////////////////////////////////////////////////////////////////// 619 | // 620 | // 621 | void OpenGLText::beginString() 622 | { 623 | m_indexOffset = 0; 624 | } 625 | 626 | /////////////////////////////////////////////////////////////////////////////////////// 627 | // 628 | // 629 | void OpenGLText::endString() 630 | { 631 | if(!m_vertices.empty()) 632 | { 633 | bs.setStates(); 634 | // Note: we could also downsize the buffer if the size is really smaller than the one currently allocated 635 | // this could be done after few iterations, if we see that the size if still smaller than the allocation... 636 | if(m_vbosz < m_vertices.size()) 637 | { 638 | #ifdef USE_PSEUDO_INSTANCING 639 | glBindBuffer( GL_TEXTURE_BUFFER, m_vbo ); // ??!?!? otherewize it crashes 640 | glBufferData(GL_TEXTURE_BUFFER, m_vertices.size()*sizeof(Vertex), &(m_vertices.front()), GL_STREAM_DRAW); 641 | glBindBuffer( GL_TEXTURE_BUFFER, 0 ); 642 | #else 643 | glBindBuffer( GL_ARRAY_BUFFER, m_vbo ); // ??!?!? otherewize it crashes 644 | glNamedBufferData(m_vbo, m_vertices.size()*sizeof(Vertex), &(m_vertices.front()), GL_STREAM_DRAW); 645 | glBindBuffer( GL_ARRAY_BUFFER, 0 ); 646 | #endif 647 | m_vbosz = m_vertices.size(); 648 | } 649 | //else glNamedBufferSubData(m_vbo, 0, m_vertices.size()*sizeof(Vertex), &(m_vertices.front())); 650 | #ifndef USE_PSEUDO_INSTANCING 651 | // 652 | // Vertex attribute format definition 653 | // 654 | static Vertex* pVtxOffset = NULL; 655 | glVertexAttribFormat(locPos , 4, GL_FLOAT, GL_FALSE, (GLuint)pVtxOffset->pos); 656 | glVertexAttribBinding(locPos, 1); 657 | #ifndef USE_FONT_METRIC_AS_TBO 658 | glVertexAttribFormat(locTc , 4, GL_FLOAT, GL_FALSE, (GLuint)pVtxOffset->tc); 659 | glVertexAttribBinding(locTc, 1); 660 | #endif 661 | #ifdef USE_INSTANCED_ARRAYS 662 | glVertexAttribIFormat(locGlyph, 1, GL_INT, (GLuint)&pVtxOffset->iattr); 663 | glVertexAttribBinding(locGlyph, 1); 664 | // 665 | // Divisor for instancing case 666 | // 667 | glVertexBindingDivisor(1, PRIMNUMBER); 668 | #endif 669 | // 670 | // bind the VBO to the buffer binding #0 671 | // 672 | glBindVertexBuffer(1, m_vbo, 0, sizeof(Vertex)); 673 | // 674 | // enable attributes to use 675 | // 676 | glEnableVertexAttribArray( locPos ); 677 | #ifndef USE_FONT_METRIC_AS_TBO 678 | glEnableVertexAttribArray( locTc ); 679 | #endif 680 | #ifdef USE_INSTANCED_ARRAYS 681 | glEnableVertexAttribArray( locGlyph ); 682 | #endif 683 | #else //USE_PSEUDO_INSTANCING 684 | glActiveTexture(GL_TEXTURE1); 685 | glBindTexture(GL_TEXTURE_BUFFER, m_texQuads); 686 | glTextureBuffer(m_texQuads, GL_RGBA32F, m_vbo); 687 | #endif 688 | #ifdef USE_FONT_METRIC_AS_TBO 689 | // 690 | // Textures/TBO for the fonts and metric 691 | // 692 | glActiveTexture(GL_TEXTURE2); 693 | glBindTexture(GL_TEXTURE_BUFFER, m_texGlyphTexOffset); 694 | glTextureBuffer(m_texGlyphTexOffset, GL_RGBA32F, m_boGlyphTexOffset); 695 | 696 | #endif 697 | 698 | glActiveTexture(GL_TEXTURE0); 699 | glBindTexture(GL_TEXTURE_2D, m_fontTex); 700 | glTextureBuffer(m_texQuads, GL_RGBA32F, m_vbo); 701 | // 702 | // activate the program 703 | // 704 | glUseProgram( m_widgetProgram ); 705 | glProgramUniform4f( m_widgetProgram, m_canvasVar, m_canvas.w, m_canvas.h, m_canvas.ratio, 0 ); 706 | // 707 | // Draw 708 | // 709 | #ifdef USE_PSEUDO_INSTANCING 710 | glDrawArrays( TOPOLOGY_PRIM, 0, m_vbosz * PRIMNUMBER); 711 | #else 712 | #ifdef USE_INSTANCED_ARRAYS 713 | glDrawArraysInstanced( TOPOLOGY_PRIM, 0, PRIMNUMBER, m_vbosz*PRIMNUMBER); 714 | #else 715 | glDrawArrays( TOPOLOGY_PRIM, 0, m_vbosz); 716 | #endif 717 | #endif //#ifdef USE_PSEUDO_INSTANCING 718 | 719 | glUseProgram( 0 ); 720 | 721 | #ifndef USE_PSEUDO_INSTANCING 722 | // switch vertex attribs back off 723 | glDisableVertexAttribArray( locPos ); 724 | #ifndef USE_FONT_METRIC_AS_TBO 725 | glDisableVertexAttribArray( locTc ); 726 | #endif 727 | #ifdef USE_INSTANCED_ARRAYS 728 | glDisableVertexAttribArray( locGlyph ); 729 | #endif 730 | #endif 731 | GLenum err = glGetError(); 732 | //assert(err == 0); 733 | m_vertices.resize(0); 734 | } 735 | } 736 | 737 | /////////////////////////////////////////////////////////////////////////////////////// 738 | // 739 | // 740 | void OpenGLText::stringSize(const char *text, float *sz) 741 | { 742 | if(!glyphInfos) 743 | return; 744 | int h = glyphInfos->pix.ascent + glyphInfos->pix.descent + glyphInfos->pix.linegap; 745 | float lPosX = 0+1; 746 | float lPosY = 0 ; 747 | 748 | float lLinePosX = lPosX; 749 | float lLinePosY = lPosY; 750 | const char* c = text; 751 | while (*c != '\0') 752 | { 753 | if ( *c == '\n') 754 | { 755 | lPosX = lLinePosX; 756 | lLinePosY -= h; 757 | lPosY = lLinePosY; 758 | } 759 | else if ( *c > 128 || *c < 0 ) 760 | { 761 | 762 | } 763 | else 764 | { 765 | GlyphInfo &g = glyphInfos->glyphs[*c]; 766 | //int pX = lPosX + g.pix.offX; 767 | //int pY = lPosY - g.pix.height - g.pix.offY; 768 | lPosX += g.pix.advance; 769 | lPosY += 0; 770 | } 771 | c++; 772 | } 773 | sz[0] = lPosX; 774 | sz[1] = lPosY + h; 775 | } 776 | 777 | /////////////////////////////////////////////////////////////////////////////////////// 778 | // 779 | // 780 | float OpenGLText::drawString( int x, int y, const char * text, int nbLines, unsigned long color) 781 | { 782 | float color4f[4]; 783 | color4f[0] = (float)(color>>24 & 0xFF)/255.0; 784 | color4f[1] = (float)(color>>16 & 0xFF)/255.0; 785 | color4f[2] = (float)(color>>8 & 0xFF)/255.0; 786 | color4f[3] = (float)(color & 0xFF)/255.0; 787 | return drawString( x, y, text, nbLines, color4f); 788 | } 789 | 790 | /////////////////////////////////////////////////////////////////////////////////////// 791 | // 792 | // 793 | float OpenGLText::drawString( int x, int y, const char * text, int nbLines, float * color4f) 794 | { 795 | if(!glyphInfos) 796 | return 0; 797 | int h = glyphInfos->pix.ascent + glyphInfos->pix.descent + glyphInfos->pix.linegap; 798 | float usedHeight = 0; 799 | float lPosX = x+1; 800 | float lPosY = y ; 801 | if (nbLines > 1) 802 | { 803 | lPosY += h * (nbLines - 1); 804 | } 805 | float lLinePosX = lPosX; 806 | float lLinePosY = lPosY; 807 | const char* c = text; 808 | Vertex v; 809 | 810 | glProgramUniform4fv(m_widgetProgram, m_color, 1, color4f); 811 | 812 | m_vertexDepth = 1.0; 813 | while (*c != '\0') 814 | { 815 | if ( *c == '\n') 816 | { 817 | lPosX = lLinePosX; 818 | lLinePosY -= h; 819 | usedHeight += h; 820 | lPosY = lLinePosY; 821 | } 822 | else if ( *c > 128 || *c < 0 ) 823 | { 824 | 825 | } 826 | else 827 | { 828 | GlyphInfo &g = glyphInfos->glyphs[*c]; 829 | int pX = lPosX + g.pix.offX; 830 | int pY = lPosY - g.pix.height - g.pix.offY; 831 | #ifdef USE_INSTANCED_ARRAYS 832 | v.setPos( pX , pY, g.pix.width, g.pix.height); 833 | #ifndef USE_FONT_METRIC_AS_TBO 834 | v.setTC ( g.norm.u, g.norm.v, g.norm.width, g.norm.height); 835 | #endif 836 | // to find back the Texture coords in atlas 837 | v.iattr = (*c); 838 | pushVertex(&v); 839 | #else 840 | #ifdef USE_QUADS 841 | v.setPos( pX , pY, 0,1); 842 | v.setTC ( g.norm.u, g.norm.v, 0,0); 843 | pushVertex(&v); 844 | v.setPos( pX + g.pix.width , pY, 0,1); 845 | v.setTC ( g.norm.u+g.norm.width, g.norm.v, 0,0); 846 | pushVertex(&v); 847 | v.setPos( pX + g.pix.width, pY + g.pix.height, 0,1); 848 | v.setTC ( g.norm.u+g.norm.width, g.norm.v+g.norm.height, 0,0); 849 | pushVertex(&v); 850 | v.setPos( pX , pY + g.pix.height, 0,1); 851 | v.setTC ( g.norm.u, g.norm.v+g.norm.height, 0,0); 852 | pushVertex(&v); 853 | #else 854 | v.setPos( pX , pY, 0,1); 855 | v.setTC ( g.norm.u, g.norm.v, 0,0); 856 | pushVertex(&v); 857 | v.setPos( pX + g.pix.width , pY, 0,1); 858 | v.setTC ( g.norm.u+g.norm.width, g.norm.v, 0,0); 859 | pushVertex(&v); 860 | v.setPos( pX , pY + g.pix.height, 0,1); 861 | v.setTC ( g.norm.u, g.norm.v+g.norm.height, 0,0); 862 | pushVertex(&v); 863 | v.setPos( pX + g.pix.width , pY, 0,1); 864 | v.setTC ( g.norm.u+g.norm.width, g.norm.v, 0,0); 865 | pushVertex(&v); 866 | v.setPos( pX + g.pix.width, pY + g.pix.height, 0,1); 867 | v.setTC ( g.norm.u+g.norm.width, g.norm.v+g.norm.height, 0,0); 868 | pushVertex(&v); 869 | v.setPos( pX, pY + g.pix.height, 0,1); 870 | v.setTC ( g.norm.u, g.norm.v+g.norm.height, 0,0); 871 | pushVertex(&v); 872 | #endif 873 | #endif 874 | lPosX += g.pix.advance; 875 | lPosY += 0; 876 | } 877 | 878 | c++; 879 | } 880 | m_vertexDepth = 1.f; 881 | return usedHeight; 882 | } 883 | 884 | /////////////////////////////////////////////////////////////////////////////////////// 885 | // 886 | // 887 | void OpenGLText::BackupStates() 888 | { 889 | if(!bs.valid) 890 | bs.backup(); 891 | } 892 | void OpenGLText::RestoreStates() 893 | { 894 | bs.restore(); 895 | } 896 | 897 | --------------------------------------------------------------------------------