22 const unsigned char *data,
bool is2D) {
24 unsigned char *tarData;
31 glEnable(GL_TEXTURE_2D);
32 glShadeModel(GL_FLAT);
33 glEnable(GL_DEPTH_TEST);
34 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
35 glGenTextures(1, &t->
id);
36 if (glGetError() != GL_NO_ERROR) {
38 while (glGetError() != GL_NO_ERROR);
42 glBindTexture(GL_TEXTURE_2D, t->
id);
43 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
44 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
45 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
47 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
49 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
50 GL_RGBA, GL_UNSIGNED_BYTE, data);
51 glDisable(GL_TEXTURE_2D);
58 sizeof(
unsigned char));
61 for (ind = 0; ind < height; ind++) {
62 const unsigned char *srcData = data + (height - 1 - ind) * offset * width;
63 tarData = t->
data + ind * offset * width;
64 memcpy(tarData, srcData, 4 * (
unsigned)width);
76 s->textures[
s->textureCount - 1] = t;
98 const char *text,
bool is2D) {
101 cairo_surface_t *surface =
NULL;
102 unsigned char *data =
NULL;
108 for (
size_t ind = 0; ind <
s->textureCount; ind++) {
110 if (
streq(def,
s->textures[ind]->def)
112 &&
streq(text,
s->textures[ind]->text)
113 &&
s->textures[ind]->fontSize==fs) {
114 s->textures[ind]->userCount++;
115 return s->textures[ind];
125 cairo_surface_destroy(surface);
void glCompDeleteTexture(glCompTex *t)
glCompTex * glCompSetAddNewTexImage(glCompSet *s, int width, int height, const unsigned char *data, bool is2D)
glCompTex * glCompSetAddNewTexLabel(glCompSet *s, char *def, int fs, const char *text, bool is2D)
static glCompTex * glCompSetAddNewTexture(glCompSet *s, int width, int height, const unsigned char *data, bool is2D)
unsigned char * glCompCreatePangoTexture(char *fontdescription, int fontsize, const char *txt, cairo_surface_t **surface, int *w, int *h)