| 34 | | osgText::Text* text1 = new osgText::Text; |
| 35 | | text1->setCharacterSize(12.0f); |
| 36 | | text1->setText("20 GOTO 10"); |
| 37 | | geode->addDrawable(text1); |
| 38 | | |
| | 34 | float windowHeight = 1024.0f; |
| | 35 | float windowWidth = 1280.0f; |
| | 36 | float margin = 50.0f; |
| | 37 | |
| | 38 | |
| | 39 | osg::Vec4 layoutColor(1.0f,1.0f,0.0f,1.0f); |
| | 40 | float layoutCharacterSize = 20.0f; |
| | 41 | |
| | 42 | { |
| | 43 | osgText::Text* text = new osgText::Text; |
| | 44 | text->setFont(font); |
| | 45 | text->setColor(layoutColor); |
| | 46 | text->setCharacterSize(layoutCharacterSize); |
| | 47 | text->setPosition(osg::Vec3(margin,windowHeight-margin,0.0f)); |
| | 48 | |
| | 49 | // the default layout is left to right, typically used in languages |
| | 50 | // originating from europe such as English, French, German, Spanish etc.. |
| | 51 | text->setLayout(osgText::Text::LEFT_TO_RIGHT); |
| | 52 | |
| | 53 | text->setText("text->setLayout(osgText::Text::LEFT_TO_RIGHT);"); |
| | 54 | geode->addDrawable(text); |
| | 55 | } |
| | 56 | |
| | 57 | { |
| | 58 | osgText::Text* text = new osgText::Text; |
| | 59 | text->setFont(font); |
| | 60 | text->setColor(layoutColor); |
| | 61 | text->setCharacterSize(layoutCharacterSize); |
| | 62 | text->setPosition(osg::Vec3(windowWidth-margin,windowHeight-margin,0.0f)); |
| | 63 | |
| | 64 | // right to left layouts would be used for hebrew or arabic fonts. |
| | 65 | text->setLayout(osgText::Text::RIGHT_TO_LEFT); |
| | 66 | |
| | 67 | text->setText("text->setLayout(osgText::Text::RIGHT_TO_LEFT);"); |
| | 68 | geode->addDrawable(text); |
| | 69 | } |
| | 70 | |
| | 71 | { |
| | 72 | osgText::Text* text = new osgText::Text; |
| | 73 | text->setFont(font); |
| | 74 | text->setColor(layoutColor); |
| | 75 | text->setPosition(osg::Vec3(margin,windowHeight-margin,0.0f)); |
| | 76 | text->setCharacterSize(layoutCharacterSize); |
| | 77 | |
| | 78 | // vertical font layout would be used for asian fonts. |
| | 79 | text->setLayout(osgText::Text::VERTICAL); |
| | 80 | |
| | 81 | text->setText("text->setLayout(osgText::Text::VERTICAL);"); |
| | 82 | geode->addDrawable(text); |
| | 83 | } |
| | 84 | |
| | 85 | |
| | 86 | osg::Vec4 fontSizeColor(0.0f,1.0f,1.0f,1.0f); |
| | 87 | float fontSizeCharacterSize = 30; |
| | 88 | |
| | 89 | osg::Vec3 cursor = osg::Vec3(margin*2,windowHeight-margin*2,0.0f); |
| | 90 | |
| | 91 | { |
| | 92 | osgText::Text* text = new osgText::Text; |
| | 93 | text->setFont(font); |
| | 94 | text->setColor(fontSizeColor); |
| | 95 | text->setCharacterSize(fontSizeCharacterSize); |
| | 96 | text->setPosition(cursor); |
| | 97 | |
| | 98 | // use text that uses 10 by 10 texels as a target resolution for fonts. |
| | 99 | text->setFontSize(10,10); // blocky but small texture memory usage |
| | 100 | |
| | 101 | text->setText("text->setFontSize(10,10); // blocky but small texture memory usage"); |
| | 102 | geode->addDrawable(text); |
| | 103 | } |
| | 104 | |
| | 105 | cursor.y() -= fontSizeCharacterSize; |
| | 106 | { |
| | 107 | osgText::Text* text = new osgText::Text; |
| | 108 | text->setFont(font); |
| | 109 | text->setColor(fontSizeColor); |
| | 110 | text->setCharacterSize(fontSizeCharacterSize); |
| | 111 | text->setPosition(cursor); |
| | 112 | |
| | 113 | // use text that uses 10 by 10 texels as a target resolution for fonts. |
| | 114 | text->setFontSize(20,20); // smoother but higher texture memory usage (but still quite low). |
| | 115 | |
| | 116 | text->setText("text->setFontSize(20,20); // smoother but higher texture memory usage (but still quite low)."); |
| | 117 | geode->addDrawable(text); |
| | 118 | } |
| | 119 | |
| | 120 | cursor.y() -= fontSizeCharacterSize; |
| | 121 | { |
| | 122 | osgText::Text* text = new osgText::Text; |
| | 123 | text->setFont(font); |
| | 124 | text->setColor(fontSizeColor); |
| | 125 | text->setCharacterSize(fontSizeCharacterSize); |
| | 126 | text->setPosition(cursor); |
| | 127 | |
| | 128 | // use text that uses 10 by 10 texels as a target resolution for fonts. |
| | 129 | text->setFontSize(40,40); // even smoother but again higher texture memory usage. |
| | 130 | |
| | 131 | text->setText("text->setFontSize(40,40); // even smoother but again higher texture memory usage."); |
| | 132 | geode->addDrawable(text); |
| | 133 | } |
| | 134 | |
| | 135 | |
| | 136 | osg::Vec4 characterSizeColor(1.0f,0.0f,1.0f,1.0f); |
| | 137 | |
| | 138 | cursor.y() -= fontSizeCharacterSize*2.0f; |
| | 139 | |
| | 140 | { |
| | 141 | osgText::Text* text = new osgText::Text; |
| | 142 | text->setFont(font); |
| | 143 | text->setColor(characterSizeColor); |
| | 144 | text->setFontSize(15,15); |
| | 145 | text->setPosition(cursor); |
| | 146 | |
| | 147 | // use text that 15 units high. |
| | 148 | text->setCharacterSize(15); // tiny |
| | 149 | |
| | 150 | text->setText("text->setCharacterSize(15.0f); // tiny"); |
| | 151 | geode->addDrawable(text); |
| | 152 | } |
| | 153 | |
| | 154 | cursor.y() -= fontSizeCharacterSize; |
| | 155 | { |
| | 156 | osgText::Text* text = new osgText::Text; |
| | 157 | text->setFont(font); |
| | 158 | text->setColor(characterSizeColor); |
| | 159 | text->setFontSize(30,30); |
| | 160 | text->setPosition(cursor); |
| | 161 | |
| | 162 | // use text that uses 10 by 10 texels as a target resolution for fonts. |
| | 163 | text->setCharacterSize(30.0f); // tiny |
| | 164 | |
| | 165 | text->setText("text->setCharacterSize(30.0f); // medium size"); |
| | 166 | geode->addDrawable(text); |
| | 167 | } |
| | 168 | |
| | 169 | cursor.y() -= fontSizeCharacterSize; |
| | 170 | { |
| | 171 | osgText::Text* text = new osgText::Text; |
| | 172 | text->setFont(font); |
| | 173 | text->setColor(characterSizeColor); |
| | 174 | text->setFontSize(40,40); |
| | 175 | text->setPosition(cursor); |
| | 176 | |
| | 177 | // use text that uses 10 by 10 texels as a target resolution for fonts. |
| | 178 | text->setCharacterSize(40.0f); // tiny |
| | 179 | |
| | 180 | text->setText("text->setCharacterSize(40.0f); // big, but can go much bigger :-)"); |
| | 181 | geode->addDrawable(text); |
| | 182 | } |
| | 183 | |
| | 184 | |
| | 185 | |
| | 186 | if (0) |
| | 187 | { |