SDL_TTF and Opengl transparency problem help please

hello i want to write text over 2d UI bar or little window like this :

but my result was bad like this:

i am using gluOrtho2D for passing 2d from 3d and my code is as follows sorry for bad english how can i write like first picture with SDL_TTF ? help please


glBindTexture(GL_TEXTURE_2D, texture);

    font=TTF_OpenFont("arial.ttf",32);

    SDL_Color color1={0,0,1};

    sFont=TTF_RenderUTF8_Blended(font,"nation1",color1);

    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, GL_RGBA, sFont->w, sFont->h, 0, GL_BGRA,GL_UNSIGNED_BYTE, sFont->pixels);

enter2D();

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glBegin(GL_QUADS);

glTexCoord2f(0,0);
glVertex2f(0.05,0.35);
glTexCoord2f(1,0);
glVertex2f(0.1,0.35);
glTexCoord2f(1,1);
glVertex2f(0.1,0.4);
glTexCoord2f(0,1);
glVertex2f(0.05,0.4);

glEnd();

glDisable(GL_BLEND);

exit2D();

enter2D();

glEnable(GL_BLEND);

glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

glBindTexture(GL_TEXTURE_2D,Uresmi);
glBegin(GL_QUADS);

glTexCoord2f(1,0); 
glVertex2f(0.2,0.3); 
glTexCoord2f(0,0);
glVertex2f(0,0.3); 
glTexCoord2f(0,1); 
glVertex2f(0,0.7); 
glTexCoord2f(1,1); 
glVertex2f(0.2,0.7); 

glEnd();


glDisable(GL_BLEND);

exit2D();

first gl_quads was text and second gl_quads was little window picture

Use this for example.

thanks for reply but it’s too complicated for me

You have other alternatives which hopefully will be more easy to use:

http://www.fltk.org/index.php