version 1.14 | | version 1.15 |
---|
| | |
* Graphical routines for drawing fonts. | | * Graphical routines for drawing fonts. |
* | | * |
* $Log$ | | * $Log$ |
| | * Revision 1.15 2003/07/02 07:26:21 donut |
| | * use GL_RGB for non-transparent textures, and fix fonts not having transparent flag set (wouldn't get paletted) |
| | * |
* Revision 1.14 2003/06/27 07:21:07 donut | | * Revision 1.14 2003/06/27 07:21:07 donut |
* memset ogl font bitmap data since the copy function leaves some (unused) parts uninitialized, which aggrivates valgrind | | * memset ogl font bitmap data since the copy function leaves some (unused) parts uninitialized, which aggrivates valgrind |
* | | * |
| | |
} | | } |
| | |
void ogl_init_font(grs_font * font){ | | void ogl_init_font(grs_font * font){ |
| | int oglflags=OGL_FLAG_ALPHA; |
int nchars = font->ft_maxchar-font->ft_minchar+1; | | int nchars = font->ft_maxchar-font->ft_minchar+1; |
int i,w,h,tw,th,x,y,curx=0,cury=0; | | int i,w,h,tw,th,x,y,curx=0,cury=0; |
char *fp; | | char *fp; |
| | |
data=malloc(tw*th); | | data=malloc(tw*th); |
memset(data,0,tw*th); | | memset(data,0,tw*th); |
gr_init_bitmap(&font->ft_parent_bitmap,BM_LINEAR,0,0,tw,th,tw,data); | | gr_init_bitmap(&font->ft_parent_bitmap,BM_LINEAR,0,0,tw,th,tw,data); |
| | gr_set_transparent(&font->ft_parent_bitmap, 1); |
| | |
font->ft_parent_bitmap.gltexture=ogl_get_free_texture(); | | if (!(font->ft_flags & FT_COLOR)) |
| | oglflags |= OGL_FLAG_NOCOLOR; |
| | ogl_init_texture(font->ft_parent_bitmap.gltexture=ogl_get_free_texture(), tw, th, oglflags); //have to init the gltexture here so the subbitmaps will find it. |
| | |
font->ft_bitmaps=(grs_bitmap*)malloc( nchars * sizeof(grs_bitmap)); | | font->ft_bitmaps=(grs_bitmap*)malloc( nchars * sizeof(grs_bitmap)); |
mprintf((0,"ogl_init_font %s, %s, nchars=%i, (%ix%i tex)\n",(font->ft_flags & FT_PROPORTIONAL)?"proportional":"fixedwidth",(font->ft_flags & FT_COLOR)?"color":"mono",nchars,tw,th)); | | mprintf((0,"ogl_init_font %s, %s, nchars=%i, (%ix%i tex)\n",(font->ft_flags & FT_PROPORTIONAL)?"proportional":"fixedwidth",(font->ft_flags & FT_COLOR)?"color":"mono",nchars,tw,th)); |
| | |
| | |
curx+=w+gap; | | curx+=w+gap; |
} | | } |
if (!(font->ft_flags & FT_COLOR)) { | | ogl_loadbmtexture_f(&font->ft_parent_bitmap, oglflags); |
//use GL_INTENSITY instead of GL_RGB | | |
if (ogl_intensity4_ok){ | | |
font->ft_parent_bitmap.gltexture->internalformat=GL_INTENSITY4; | | |
font->ft_parent_bitmap.gltexture->format=GL_LUMINANCE; | | |
}else if (ogl_luminance4_alpha4_ok){ | | |
font->ft_parent_bitmap.gltexture->internalformat=GL_LUMINANCE4_ALPHA4; | | |
font->ft_parent_bitmap.gltexture->format=GL_LUMINANCE_ALPHA; | | |
}else if (ogl_rgba2_ok){ | | |
font->ft_parent_bitmap.gltexture->internalformat=GL_RGBA2; | | |
font->ft_parent_bitmap.gltexture->format=GL_RGBA; | | |
}else{ | | |
font->ft_parent_bitmap.gltexture->internalformat=ogl_rgba_format; | | |
font->ft_parent_bitmap.gltexture->format=GL_RGBA; | | |
} | | |
} | | |
ogl_loadbmtexture_m(&font->ft_parent_bitmap,0); | | |
} | | } |
| | |
int ogl_internal_string(int x, int y, char *s ) | | int ogl_internal_string(int x, int y, char *s ) |