1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
void Ctext::DrawText(char message[])
{
//Création de la texture du sprite
SDL_Surface *temp;
glGenTextures (1, & surface);
glBindTexture (GL_TEXTURE_2D, surface);
// Paramétrage de la texture.
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//temp = TTF_RenderText_Solid(font, message, color);
temp = TTF_RenderText_Solid(font, message, color);
// Jonction entre OpenGL et SDL.
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA, temp->w, temp->h, 0,
GL_RGBA, GL_UNSIGNED_BYTE, temp-> pixels);
SDL_FreeSurface(temp);
glEnable(GL_ALPHA_TEST);
glBegin(GL_QUADS);
glTexCoord2f (0, 0);
glVertex2f(rectdest.x, rectdest.y);
glTexCoord2f (0, 1);
glVertex2f(rectdest.x, rectdest.y + rectsrc.h);
glTexCoord2f (1, 1);
glVertex2f(rectdest.x + rectsrc.w, rectdest.y + rectsrc.h);
glTexCoord2f (1, 0);
glVertex2f(rectdest.x + rectsrc.w, rectdest.y);
glEnd();
} |