10 void RrTextureFreeContents(struct RrTexture *tex)
16 free(tex->data.text.string);
19 glDeleteTextures(1, &tex->data.rgba.texid);
22 tex->type = RR_TEXTURE_NONE;
25 void RrTextureSetRGBA(struct RrSurface *sur,
34 struct RrTexture *tex = RrSurfaceTexture(sur, texnum);
37 RrTextureFreeContents(tex);
38 tex->type = RR_TEXTURE_RGBA;
43 glGenTextures(1, &num);
44 tex->data.rgba.texid = num;
45 glBindTexture(GL_TEXTURE_2D, num);
46 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
47 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
48 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
49 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
50 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
51 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
52 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h,
53 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
56 void RrTextureSetText(struct RrSurface *sur,
60 struct RrColor *color,
63 struct RrTexture *tex = RrSurfaceTexture(sur, texnum);
67 RrTextureFreeContents(tex);
68 tex->type = RR_TEXTURE_TEXT;
69 tex->data.text.font = font;
70 tex->data.text.layout = layout;
71 tex->data.text.color = *color;
74 tex->data.text.string = malloc(l);
75 memcpy(tex->data.text.string, text, l);
78 void RrTextureSetNone(struct RrSurface *sur,
81 struct RrTexture *tex = RrSurfaceTexture(sur, texnum);
84 RrTextureFreeContents(tex);
87 void RrTexturePaint(struct RrSurface *sur, struct RrTexture *tex)
91 glEnable(GL_TEXTURE_2D);
97 assert(tex->data.text.font);
98 col.r = tex->data.text.color.r;
99 col.g = tex->data.text.color.g;
100 col.b = tex->data.text.color.b;
101 col.a = tex->data.text.color.a;
103 GlftRenderString(tex->data.text.font->font, tex->data.text.string,
104 strlen(tex->data.text.string), &col,
105 RrSurfaceX(sur) + 2, RrSurfaceY(sur) + 4);
108 glDisable(GL_TEXTURE_2D);