aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Image.c65
1 files changed, 50 insertions, 15 deletions
diff --git a/generic/Image.c b/generic/Image.c
index 2a0f7c3..9b2bfff 100644
--- a/generic/Image.c
+++ b/generic/Image.c
@@ -655,6 +655,7 @@ ZnImageTex(ZnImage image,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glGetError();
if (ZnImageIsBitmap(image)) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY4,
this->bits->t_width, this->bits->t_height,
@@ -665,6 +666,11 @@ ZnImageTex(ZnImage image,
this->bits->t_width, this->bits->t_height,
0, GL_RGBA, GL_UNSIGNED_BYTE, this->bits->t_bits);
}
+ if (glGetError() != GL_NO_ERROR) {
+ ZnWarning("Can't allocate the texture for image ");
+ ZnWarning(ZnNameOfImage(image));
+ ZnWarning("\n");
+ }
glBindTexture(GL_TEXTURE_2D, 0);
}
@@ -994,7 +1000,7 @@ ZnGetTexFont(ZnWInfo *wi,
int width, height;
unsigned int texw, texh;
GLfloat xstep, ystep;
- GLuint max_tex_size[1];
+ ZnBool increase_h = False;
if (!inited) {
Tcl_InitHashTable(&font_textures, TCL_ONE_WORD_KEYS);
@@ -1017,13 +1023,8 @@ ZnGetTexFont(ZnWInfo *wi,
txf->lut = NULL;
txf->tkfont = font;
- entry = Tcl_CreateHashEntry(&font_textures, (char *) font, &new);
- Tcl_SetHashValue(entry, (ClientData) txf);
- txf->hash = entry;
-
/*printf("Chargement de la texture pour la fonte %s\n",
ZnNameOfTexFont(tfi));*/
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, max_tex_size);
fontinfo = SuckGlyphsFromServer(wi, txf->tkfont);
if (fontinfo == NULL) {
goto error;
@@ -1034,16 +1035,22 @@ ZnGetTexFont(ZnWInfo *wi,
/*
* Initial size of texture.
- * Assume that max_tex_size is at least 128 texels.
*/
- texw = 128;
+ texw = texh = wi->max_tex_size;
texh = 64;
while (texh < (unsigned int) (txf->ascent+txf->descent)) {
texh *= 2;
}
- if (texh > max_tex_size[0]) {
+ /*
+ * This is temporarily disabled until we find out
+ * how to reliably get max_tex_size up front without
+ * waiting for the window mapping.
+ */
+#ifdef MAX_TEX_SIZE
+ if (texh > wi->max_tex_size) {
goto error;
}
+#endif
xstep = 0/*0.5 / texw*/;
ystep = 0/*0.5 / texh*/;
@@ -1109,8 +1116,8 @@ ZnGetTexFont(ZnWInfo *wi,
}
}
- /* If a fit was found, use that character; otherwise, advance a line
- in the texture. */
+ /* If a fit was found, use that character; otherwise
+ * advance a line in the texture. */
if (foundWidthFit) {
if (height > maxheight) {
maxheight = height;
@@ -1127,25 +1134,37 @@ ZnGetTexFont(ZnWInfo *wi,
px = gap;
maxheight = height;
if ((unsigned int) (py + height + gap) >= texh) {
- if (texh*2 < max_tex_size[0]) {
+#ifdef MAX_TEX_SIZE
+ if (texh*2 < wi->max_tex_size) {
+#else
+ if (increase_h) {
+ increase_h = False;
+#endif
texh *= 2;
ZnFree(txf->teximage);
txf->teximage = ZnMalloc(texw * texh * sizeof(unsigned char));
strcpy(glist, glist2);
goto restart;
}
- else if (texw*2 < max_tex_size[0]) {
+#ifdef MAX_TEX_SIZE
+ else if (texw*2 < wi->max_tex_size) {
+#else
+ else {
+ increase_h = True;
+#endif
texw *= 2;
ZnFree(txf->teximage);
txf->teximage = ZnMalloc(texw * texh * sizeof(unsigned char));
strcpy(glist, glist2);
goto restart;
}
+#ifdef MAX_TEX_SIZE
else {
/* Overflowed texture space */
ZnWarning("Font texture overflow\n");
goto error;
}
+#endif
}
c = i;
}
@@ -1237,8 +1256,13 @@ ZnGetTexFont(ZnWInfo *wi,
ZnFree(txf->teximage);
txf->teximage = NULL;
}
+ ZnFree(txf);
+ ZnWarning("Cannot load font texture for font ");
+ ZnWarning(Tk_NameOfFont(font));
+ ZnWarning("\n");
return 0;
}
+
memset(txf->lut, 0, txf->range * sizeof(ZnTexGVI *));
for (i = 0; i < txf->num_glyphs; i++) {
txf->lut[txf->tgi[i].c - txf->min_glyph] = &txf->tgvi[i];
@@ -1251,6 +1275,10 @@ ZnGetTexFont(ZnWInfo *wi,
ZnFree(fontinfo);
ZnFree(glist);
ZnFree(glist2);
+
+ entry = Tcl_CreateHashEntry(&font_textures, (char *) font, &new);
+ Tcl_SetHashValue(entry, (ClientData) txf);
+ txf->hash = entry;
}
/*
@@ -1317,8 +1345,15 @@ ZnTexFontTex(ZnTexFontInfo tfi)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY4, txf->tex_width, txf->tex_height,
- 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, txf->teximage);
+ glGetError();
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY4, txf->tex_width,
+ txf->tex_height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE,
+ txf->teximage);
+ if (glGetError() != GL_NO_ERROR) {
+ ZnWarning("Can't allocate the texture for font ");
+ ZnWarning(ZnNameOfTexFont(tfi));
+ ZnWarning("\n");
+ }
glBindTexture(GL_TEXTURE_2D, 0);
}