Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenfont/intern/blf_glyph.c
| Show First 20 Lines • Show All 259 Lines • ▼ Show 20 Lines | static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) | ||||
| i = (int)((gc->p2_width - (gc->pad * 2)) / gc->glyph_width_max); | i = (int)((gc->p2_width - (gc->pad * 2)) / gc->glyph_width_max); | ||||
| gc->p2_height = (int)blf_next_p2( | gc->p2_height = (int)blf_next_p2( | ||||
| (unsigned int)(((gc->glyphs_len_max / i) + 1) * gc->glyph_height_max + (gc->pad * 2))); | (unsigned int)(((gc->glyphs_len_max / i) + 1) * gc->glyph_height_max + (gc->pad * 2))); | ||||
| if (gc->p2_height > font->tex_size_max) { | if (gc->p2_height > font->tex_size_max) { | ||||
| gc->p2_height = font->tex_size_max; | gc->p2_height = font->tex_size_max; | ||||
| } | } | ||||
| unsigned char *pixels = MEM_callocN((size_t)gc->p2_width * (size_t)gc->p2_height, | |||||
| "BLF texture init"); | |||||
| GPUTexture *tex = GPU_texture_create_nD( | GPUTexture *tex = GPU_texture_create_nD( | ||||
| gc->p2_width, gc->p2_height, 0, 2, pixels, GPU_R8, GPU_DATA_UNSIGNED_BYTE, 0, false, error); | gc->p2_width, gc->p2_height, 0, 2, NULL, GPU_R8, GPU_DATA_UNSIGNED_BYTE, 0, false, error); | ||||
| MEM_freeN(pixels); | |||||
| gc->textures[gc->texture_current] = tex; | gc->textures[gc->texture_current] = tex; | ||||
| GPU_texture_bind(tex, 0); | GPU_texture_bind(tex, 0); | ||||
| GPU_texture_wrap_mode(tex, false); | GPU_texture_wrap_mode(tex, false); | ||||
| GPU_texture_filters(tex, GPU_NEAREST, GPU_LINEAR); | GPU_texture_filters(tex, GPU_NEAREST, GPU_LINEAR); | ||||
| GPU_texture_unbind(tex); | GPU_texture_unbind(tex); | ||||
| } | } | ||||
| GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) | GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) | ||||
| ▲ Show 20 Lines • Show All 379 Lines • Show Last 20 Lines | |||||