20 const unsigned char *
data,
bool is2D) {
22 unsigned char *tarData;
29 glEnable(GL_TEXTURE_2D);
30 glShadeModel(GL_FLAT);
31 glEnable(GL_DEPTH_TEST);
32 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
33 glGenTextures(1, &t->
id);
34 if (glGetError() != GL_NO_ERROR) {
36 while (glGetError() != GL_NO_ERROR);
40 glBindTexture(GL_TEXTURE_2D, t->
id);
41 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
42 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
43 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
45 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
47 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
48 GL_RGBA, GL_UNSIGNED_BYTE,
data);
49 glDisable(GL_TEXTURE_2D);
56 sizeof(
unsigned char));
59 for (ind = 0; ind < height; ind++) {
60 const unsigned char *srcData =
data + (height - 1 - ind) *
offset * width;
62 memcpy(tarData, srcData, 4 * (
unsigned)width);
74 s->textures[
s->textureCount - 1] = t;
99 cairo_surface_t *surface =
NULL;
106 for (
size_t ind = 0; ind <
s->textureCount; ind++) {
108 if (
streq(def,
s->textures[ind]->def)
110 &&
streq(text,
s->textures[ind]->text)
111 &&
s->textures[ind]->fontSize==fs) {
112 s->textures[ind]->userCount++;
113 return s->textures[ind];
123 cairo_surface_destroy(surface);
glCompTex * glCompSetAddNewTexLabel(glCompSet *s, char *def, int fs, char *text, bool is2D)
void glCompDeleteTexture(glCompTex *t)
glCompTex * glCompSetAddNewTexImage(glCompSet *s, int width, int height, const unsigned char *data, bool is2D)
static glCompTex * glCompSetAddNewTexture(glCompSet *s, int width, int height, const unsigned char *data, bool is2D)
unsigned char * glCompCreatePangoTexture(char *fontdescription, int fontsize, char *txt, cairo_surface_t **surface, int *w, int *h)