ilA_img *ilG_gui_textlayout_render(ilG_gui_textlayout *self, float col[4], enum ilG_gui_textoptions opts) { (void)opts; unsigned w = 0, h = 0; unsigned x = 0, y = 0; int bx = 0, by = 0; int scale = 64; unsigned i; self->cairo_ft_face = cairo_ft_font_face_create_for_ft_face(self->ft_face, 0); self->hb_ft_face = hb_ft_face_create(self->ft_face, NULL); x *= scale; y *= scale; self->cairo_glyphs = calloc(self->glyph_count, sizeof(cairo_glyph_t)); for (i = 0; i < self->glyph_count; i++) { self->cairo_glyphs[i].index = self->glyph_info[i].codepoint; self->cairo_glyphs[i].x = (x + self->glyph_pos[i].x_offset)/scale; self->cairo_glyphs[i].y = (y + self->glyph_pos[i].y_offset)/scale; x += self->glyph_pos[i].x_advance; y += self->glyph_pos[i].y_advance; } ilG_gui_textlayout_getExtents(self, &w, &h, &bx, &by, NULL, NULL); self->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); self->cr = cairo_create(self->surface); cairo_translate(self->cr, -bx, 1-by); cairo_set_source_rgba(self->cr, col[0], col[1], col[2], col[3]); cairo_set_font_face(self->cr, self->cairo_ft_face); cairo_set_font_size(self->cr, self->pt); cairo_show_glyphs(self->cr, self->cairo_glyphs, self->glyph_count); cairo_surface_flush(self->surface); ilA_img *preswizzle = ilA_img_fromdata(cairo_image_surface_get_data(self->surface), w, h, 8, ILA_IMG_RGBA); /* R G B A | 0x * B 0 0 1 0 | 2 * G 0 1 0 0 | 4 * R 1 0 0 0 | 8 * A 0 0 0 1 | 1 */ ilA_img *img = ilA_img_bgra_to_rgba(preswizzle);//ilA_img_swizzle(preswizzle, 0x2481); ilA_img_free(preswizzle); return img; }
void ilG_tex_loadcube(ilG_tex *tex, struct ilA_img faces[6]) { static const GLenum targets[6] = { GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_NEGATIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, }; tex->target = GL_TEXTURE_CUBE_MAP; glGenTextures(1, &tex->object); glBindTexture(GL_TEXTURE_CUBE_MAP, tex->object); for (unsigned i = 0; i < 6; i++) { glTexImage2D(targets[i], 0, getImgIFormat(&faces[i]), faces[i].width, faces[i].height, 0, getImgFormat(&faces[i]), getImgType(&faces[i]), faces[i].data); ilA_img_free(faces[i]); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST); }