aboutsummaryrefslogtreecommitdiff
path: root/generic/Image.c
diff options
context:
space:
mode:
authorlecoanet2003-01-14 10:51:36 +0000
committerlecoanet2003-01-14 10:51:36 +0000
commit4a8d47f1b9dfc7fecc3e31ebfa80a388318d86a9 (patch)
tree6c68775ce176287f353d9ec240fd3f818c470c90 /generic/Image.c
parent2d550b335319509a46a77a7bb0ae65504c40e42b (diff)
downloadtkzinc-4a8d47f1b9dfc7fecc3e31ebfa80a388318d86a9.zip
tkzinc-4a8d47f1b9dfc7fecc3e31ebfa80a388318d86a9.tar.gz
tkzinc-4a8d47f1b9dfc7fecc3e31ebfa80a388318d86a9.tar.bz2
tkzinc-4a8d47f1b9dfc7fecc3e31ebfa80a388318d86a9.tar.xz
* Correction d'un bug lors de la d�sallocation des textures:
le contexte graphique GL n'�tait pas n�cessairement correctement positionn�, ce qui provoquait la lib�ration dans le mauvais contexte donc le mauvais widget. Visible au travers d'un bug de dessin de textes sous forme de carr�s noirs mais vrai aussi pour les images.
Diffstat (limited to 'generic/Image.c')
-rw-r--r--generic/Image.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/generic/Image.c b/generic/Image.c
index 10566a6..7d01de9 100644
--- a/generic/Image.c
+++ b/generic/Image.c
@@ -52,7 +52,6 @@ static Tcl_HashTable images;
static Tcl_HashTable font_textures;
#endif
-
typedef struct _ImageStruct {
union {
struct {
@@ -650,7 +649,9 @@ ZnFreeImage(ZnImage image)
}
if (this->for_gl) {
#ifdef GLX
- if (this->i.gl.texobj) {
+ WidgetInfo *wi = this->i.gl.wi;
+ if (this->i.gl.texobj && wi->win) {
+ glXMakeCurrent(wi->dpy, ZnWindowId(wi->win), wi->gl_context);
glDeleteTextures(1, &this->i.gl.texobj);
}
#endif
@@ -1231,13 +1232,14 @@ ZnGetTexFont(WidgetInfo *wi,
Tcl_InitHashTable(&font_textures, TCL_STRING_KEYS);
inited = 1;
}
+
entry = Tcl_FindHashEntry(&font_textures, fontname);
if (entry != NULL) {
- /*printf("found font: %s\n", fontname);*/
+ /*printf("found font: %d |%s|\n", wi, fontname);*/
txf = (TexFont *) Tcl_GetHashValue(entry);
}
else {
- /*printf("new font: |%s|\n", fontname);*/
+ /*printf("new font: %d |%s|\n", wi, fontname);*/
txf = ZnMalloc(sizeof(TexFont));
if (txf == NULL) {
return NULL;
@@ -1277,7 +1279,7 @@ ZnGetTexFont(WidgetInfo *wi,
tfi->txf = txf;
tfi->next = txf->tfi;
txf->tfi = tfi;
-
+
return tfi;
}
@@ -1385,6 +1387,7 @@ ZnTexFontTex(ZnTexFontInfo tfi)
getMetric(fontinfo, glist[i], tgi);
width = tgi->width;
height = tgi->height;
+
if ((height > 0) && (width > 0)) {
for (j = i; j < txf->num_glyphs;) {
if ((height > 0) && (width > 0)) {
@@ -1454,7 +1457,7 @@ ZnTexFontTex(ZnTexFontInfo tfi)
/* Assign glyph's texture coordinate. */
tgi->x = px;
tgi->y = py;
-
+
/* Advance by glyph width, remaining in the current line. */
px += width + gap;
}
@@ -1497,9 +1500,9 @@ ZnTexFontTex(ZnTexFontInfo tfi)
}
txf->tex_width = texw;
txf->tex_height = texh;
- /*printf("texture width: %g, texture height: %g\n", texw, texh);*/
- /* printf("min glyph: (%d) \"%c\", max glyph: (%d) \"%c\"\n",
- min_glyph, min_glyph, max_glyph, max_glyph);*/
+ /*printf("texture width: %g, texture height: %g\n", texw, texh);
+ printf("min glyph: (%d) \"%c\", max glyph: (%d) \"%c\"\n",
+ min_glyph, min_glyph, max_glyph, max_glyph);*/
txf->min_glyph = min_glyph;
txf->range = max_glyph - min_glyph + 1;
@@ -1523,8 +1526,8 @@ ZnTexFontTex(ZnTexFontInfo tfi)
if (!this->texobj) {
glGenTextures(1, &this->texobj);
- /*printf("creation texture %d pour la fonte %s\n",
- this->texobj, ZnNameOfTexFont(tfi));*/
+ /*printf("%d creation texture %d pour la fonte %s\n",
+ this->wi, this->texobj, ZnNameOfTexFont(tfi));*/
glBindTexture(GL_TEXTURE_2D, this->texobj);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
@@ -1535,6 +1538,7 @@ ZnTexFontTex(ZnTexFontInfo tfi)
glBindTexture(GL_TEXTURE_2D, 0);
}
+ /*printf("%d utilisation de la texture %d\n", this->wi, this->texobj);*/
return this->texobj;
error:
@@ -1584,6 +1588,7 @@ void
ZnFreeTexFont(ZnTexFontInfo tfi)
{
TexFontInfo *this = ((TexFontInfo *) tfi);
+ WidgetInfo *wi = this->wi;
TexFont *txf = this->txf;
TexFontInfo *prev, *scan;
@@ -1610,9 +1615,10 @@ ZnFreeTexFont(ZnTexFontInfo tfi)
else {
prev->next = this->next;
}
- if (this->texobj) {
- /*printf("Libération de la texture %d pour la fonte %s\n",
- this->texobj, ZnNameOfTexFont(tfi));*/
+ if (this->texobj && wi->win) {
+ /*printf("%d Libération de la texture %d pour la fonte %s\n",
+ wi, this->texobj, ZnNameOfTexFont(tfi));*/
+ glXMakeCurrent(wi->dpy, ZnWindowId(wi->win), wi->gl_context);
glDeleteTextures(1, &this->texobj);
}
@@ -1621,8 +1627,7 @@ ZnFreeTexFont(ZnTexFontInfo tfi)
* deallocate the structures.
*/
if (txf->tfi == NULL) {
- /*printf("destruction complète du txf pour %s\n",
- ZnNameOfTexFont(tfi));*/
+ /*printf("%d destruction complète du txf pour %s\n", this->wi, ZnNameOfTexFont(tfi));*/
ZnFree(txf->tgi);
ZnFree(txf->tgvi);
ZnFree(txf->lut);