- var pstext, psausgabe: PSDL_Surface;
- //TTF initialisieren und Schrift einladen
- TTF_Init;
- //Text in ein Surface rendern
- pstext := TTF_RenderText_Solid(font,pChar(text), color);
- //Nächste Potenzen von 2 für das eigentliche Surface berechen
- w := NextPowerOfTwo(pstext.w);
- h := NextPowerOfTwo(pstext.h);
- //Leeres Surface erstellen und gerenderten Text rüberkopieren
- psausgabe := SDL_CreateRGBSurface(SDL_SWSURFACE,w,h,32, rmask, gmask, bmask, amask);
- SDL_BlitSurface(pstext,0,psausgabe,0);
- //Textur erstellen
- glGenTextures(1,@texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, 4, w, h, 0, GL_RGBA,
- GL_UNSIGNED_BYTE, psausgabe.pixels );
- //Texture an ein Quad binden und ausgeben
- glEnable(GL_TEXTURE_2D);
- glColor4f(1,1,1,0);
- glBegin(GL_QUADS);
- glTexCoord2f(0,0); glVertex3f(location.x, location.y+h ,0);
- glTexCoord2f(0,1); glVertex3f(location.y, location.y ,0);
- glTexCoord2f(1,1); glVertex3f(location.x+w, location.y ,0);
- glTexCoord2f(1,0); glVertex3f(location.x+w, location.y+h ,0);
- glEnd;
- //Alles freigeben
- SDL_FreeSurface(pstext);
- SDL_FreeSurface(psausgabe);
- glDeleteTextures(1, @texture);