aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-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);