|
1 | 1 | // Begin CVS Header |
2 | 2 | // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/layout/CLLayoutRenderer.cpp,v $ |
3 | | -// $Revision: 1.5.2.4 $ |
| 3 | +// $Revision: 1.5.2.5 $ |
4 | 4 | // $Name: $ |
5 | 5 | // $Author: gauges $ |
6 | | -// $Date: 2010/10/05 18:58:45 $ |
| 6 | +// $Date: 2010/10/06 04:31:25 $ |
7 | 7 | // End CVS Header |
8 | 8 |
|
9 | 9 | // Copyright (C) 2010 by Pedro Mendes, Virginia Tech Intellectual |
@@ -1377,8 +1377,8 @@ void CLLayoutRenderer::draw_text(const CLTextTextureSpec* pTexture, double x, do |
1377 | 1377 | // we draw a rectangle in the current stroke color. At places where the texture is black, the underlying color should be seen. |
1378 | 1378 | // load the texture |
1379 | 1379 | // enable 2D texturing |
1380 | | - glBindTexture(GL_TEXTURE_2D, pTexture->mTextureName); |
1381 | 1380 | glEnable(GL_TEXTURE_2D); |
| 1381 | + glBindTexture(GL_TEXTURE_2D, pTexture->mTextureName); |
1382 | 1382 | glMatrixMode(GL_MODELVIEW); |
1383 | 1383 | glPushMatrix(); |
1384 | 1384 | glTranslated(xOffset, yOffset, zOffset); |
@@ -3205,11 +3205,26 @@ void CLLayoutRenderer::update_textures_and_colors() |
3205 | 3205 | { |
3206 | 3206 | // add the texture although it might be NULL |
3207 | 3207 | //std::cout << "Creating new texture for text glyph: " << pTG->getId() << std::endl; |
3208 | | - CLTextTextureSpec* pTexture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, this->mZoomFactor); |
| 3208 | + std::pair<CLTextTextureSpec*, GLubyte*> texture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, this->mZoomFactor); |
| 3209 | + |
3209 | 3210 | //std::cout << "Created texture at " << pTexture << " for text \"" << text << "\"" << std::endl; |
3210 | 3211 | //std::cout << "texture id: " << pTexture->mTextureName << std::endl; |
3211 | | - pos->second[text] = pTexture; |
3212 | | - this->mTextGlyphMap[pTG] = pTexture; |
| 3212 | + if (texture.first != NULL && texture.second != NULL) |
| 3213 | + { |
| 3214 | + glGenTextures(1, &texture.first->mTextureName); |
| 3215 | + assert(texture.first->mTextureName != 0); |
| 3216 | + glBindTexture(GL_TEXTURE_2D, texture.first->mTextureName); |
| 3217 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 3218 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 3219 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 3220 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 3221 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 3222 | + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture.first->mTextureWidth, texture.first->mTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texture.second); |
| 3223 | + delete[] texture.second; |
| 3224 | + } |
| 3225 | + |
| 3226 | + pos->second[text] = texture.first; |
| 3227 | + this->mTextGlyphMap[pTG] = texture.first; |
3213 | 3228 | } |
3214 | 3229 | else |
3215 | 3230 | { |
@@ -3237,13 +3252,28 @@ void CLLayoutRenderer::update_textures_and_colors() |
3237 | 3252 | newScale = this->mZoomFactor; |
3238 | 3253 | } |
3239 | 3254 |
|
3240 | | - pTexture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, newScale); |
| 3255 | + std::pair<CLTextTextureSpec*, GLubyte*> texture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, newScale); |
| 3256 | + |
3241 | 3257 | // check if the texture has a size that is supported |
3242 | 3258 | //std::cout << "Created texture at " << pTexture << " for text \"" << text << "\"" << std::endl; |
3243 | 3259 | //std::cout << "texture id: " << pTexture->mTextureName << std::endl; |
3244 | | - pos2->second = pTexture; |
| 3260 | + if (texture.first != NULL && texture.second != NULL) |
| 3261 | + { |
| 3262 | + glGenTextures(1, &texture.first->mTextureName); |
| 3263 | + assert(texture.first->mTextureName != 0); |
| 3264 | + glBindTexture(GL_TEXTURE_2D, texture.first->mTextureName); |
| 3265 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 3266 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 3267 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 3268 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 3269 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 3270 | + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture.first->mTextureWidth, texture.first->mTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texture.second); |
| 3271 | + delete[] texture.second; |
| 3272 | + } |
| 3273 | + |
| 3274 | + pos2->second = texture.first; |
3245 | 3275 | //std::cout << "rescaled texture id: " << pTexture->mTextureName << std::endl; |
3246 | | - this->mTextGlyphMap[pTG] = pTexture; |
| 3276 | + this->mTextGlyphMap[pTG] = texture.first; |
3247 | 3277 | } |
3248 | 3278 | else |
3249 | 3279 | { |
@@ -3640,11 +3670,26 @@ void CLLayoutRenderer::update_textures_and_colors(const CLGroup* pGroup, double |
3640 | 3670 | if (pos2 == pos->second.end()) |
3641 | 3671 | { |
3642 | 3672 | // add the texture although it might be NULL |
3643 | | - CLTextTextureSpec* pTexture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, this->mZoomFactor); |
| 3673 | + std::pair<CLTextTextureSpec*, GLubyte*> texture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, this->mZoomFactor); |
| 3674 | + |
3644 | 3675 | //std::cout << "No texture found. Created texture at " << pTexture << " for text \"" << text << "\"" << std::endl; |
3645 | 3676 | //std::cout << "texture id: " << pTexture->mTextureName << std::endl; |
3646 | | - pos->second[text] = pTexture; |
3647 | | - this->mTextMap[pText] = pTexture; |
| 3677 | + if (texture.first != NULL && texture.second != NULL) |
| 3678 | + { |
| 3679 | + glGenTextures(1, &texture.first->mTextureName); |
| 3680 | + assert(texture.first->mTextureName != 0); |
| 3681 | + glBindTexture(GL_TEXTURE_2D, texture.first->mTextureName); |
| 3682 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 3683 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 3684 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 3685 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 3686 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 3687 | + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture.first->mTextureWidth, texture.first->mTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texture.second); |
| 3688 | + delete[] texture.second; |
| 3689 | + } |
| 3690 | + |
| 3691 | + pos->second[text] = texture.first; |
| 3692 | + this->mTextMap[pText] = texture.first; |
3648 | 3693 | } |
3649 | 3694 | else |
3650 | 3695 | { |
@@ -3673,11 +3718,26 @@ void CLLayoutRenderer::update_textures_and_colors(const CLGroup* pGroup, double |
3673 | 3718 | newScale = this->mZoomFactor; |
3674 | 3719 | } |
3675 | 3720 |
|
3676 | | - pTexture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, newScale); |
| 3721 | + std::pair<CLTextTextureSpec*, GLubyte*> texture = (*this->mpFontRenderer)(fontSpec.mFamily, fontSpec.mSize, text, fontSpec.mWeight, fontSpec.mStyle, newScale); |
| 3722 | + |
3677 | 3723 | //std::cout << "Created texture at " << pTexture << " for text \"" << text << "\"" << std::endl; |
3678 | 3724 | //std::cout << "texture id: " << pTexture->mTextureName << std::endl; |
3679 | | - pos2->second = pTexture; |
3680 | | - this->mTextMap[pText] = pTexture; |
| 3725 | + if (texture.first != NULL && texture.second != NULL) |
| 3726 | + { |
| 3727 | + glGenTextures(1, &texture.first->mTextureName); |
| 3728 | + assert(texture.first->mTextureName != 0); |
| 3729 | + glBindTexture(GL_TEXTURE_2D, texture.first->mTextureName); |
| 3730 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 3731 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 3732 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 3733 | + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 3734 | + glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); |
| 3735 | + glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, texture.first->mTextureWidth, texture.first->mTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, texture.second); |
| 3736 | + delete[] texture.second; |
| 3737 | + } |
| 3738 | + |
| 3739 | + pos2->second = texture.first; |
| 3740 | + this->mTextMap[pText] = texture.first; |
3681 | 3741 | } |
3682 | 3742 | else |
3683 | 3743 | { |
|
0 commit comments