dynamic rendering of utf8 characters such as umlauts by using ttf (wip)
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4769 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -348,6 +348,34 @@ Texture *textureload(const char *name, int clamp, bool mipmap, bool canreduce)
|
||||
return t;
|
||||
}
|
||||
|
||||
Texture *createtexturefromsurface(const char *name, SDL_Surface *s)
|
||||
{
|
||||
string pname;
|
||||
copystring(pname, name);
|
||||
path(pname);
|
||||
Texture *t = textures.access(pname);
|
||||
if(!t)
|
||||
{
|
||||
char *key = newstring(pname);
|
||||
t = &textures[key];
|
||||
t->name = key;
|
||||
}
|
||||
|
||||
GLuint tnum;
|
||||
glGenTextures(1, &tnum);
|
||||
GLenum format = texformat(s->format->BitsPerPixel);
|
||||
createtexture(tnum, s->w, s->h, s->pixels, 0, true, false, format);
|
||||
|
||||
t->xs = s->w;
|
||||
t->ys = s->h;
|
||||
t->bpp = s->format->BitsPerPixel;
|
||||
t->clamp = 0;
|
||||
t->mipmap = true;
|
||||
t->canreduce = false;
|
||||
t->id = tnum;
|
||||
return t;
|
||||
}
|
||||
|
||||
struct Slot
|
||||
{
|
||||
string name;
|
||||
@@ -665,3 +693,28 @@ void cleanuptmus()
|
||||
loopi(MAXTMUS) tmus[i] = invalidtmu;
|
||||
}
|
||||
|
||||
|
||||
// only works on 32 bit surfaces with alpha in 4th byte!
|
||||
void blitsurface(SDL_Surface *dst, SDL_Surface *src, int x, int y)
|
||||
{
|
||||
uchar *dstp = (uchar *)dst->pixels + y*dst->pitch + x*4,
|
||||
*srcp = (uchar *)src->pixels;
|
||||
int dstpitch = dst->pitch - 4*src->w,
|
||||
srcpitch = src->pitch - 4*src->w;
|
||||
loop(dy, src->h)
|
||||
{
|
||||
loop(dx, src->w)
|
||||
{
|
||||
uint k1 = (255U - srcp[3]) * dstp[3], k2 = srcp[3] * 255U, kmax = max(dstp[3], srcp[3]), kscale = max(kmax * 255U, 1U);
|
||||
dstp[0] = (dstp[0]*k1 + srcp[0]*k2) / kscale;
|
||||
dstp[1] = (dstp[1]*k1 + srcp[1]*k2) / kscale;
|
||||
dstp[2] = (dstp[2]*k1 + srcp[2]*k2) / kscale;
|
||||
dstp[3] = kmax;
|
||||
dstp += 4;
|
||||
srcp += 4;
|
||||
}
|
||||
dstp += dstpitch;
|
||||
srcp += srcpitch;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user