XdrawString+double buffer

dragoran dragoran at feuerpokemon.de
Mon Jul 31 08:48:00 PDT 2006

Brian Paul wrote:
> dragoran wrote:
>> Hello
>> I am working on a wrapper around glxSwapbuffers. I want to display 
>> text in openglapps.
>> I have tryed many different things like textures,gldrawpixels, etc. 
>> but none of the works in all apps.
>> ut2004 does not even like the gldrawpixel version.
>> so I tryed using Xdrawstring which works in all of this apps but it 
>> flackers because of double buffering.
>> how can I avoid this?
>> here is my code, it simply displays "test" on the appwindow...
>> void glXSwapBuffers(Display* dpy, GLXDrawable drawable) {
>> #ifdef DEBUG
>>    fprintf(stderr,"about to draw hud ;)\n");
>> #endif
>>    Colormap cmap;
>>    XColor c0, c1;
>>    cmap = DefaultColormap(dpy, 0);
>>    XAllocNamedColor(dpy, cmap, "red", &c1, &c0);
>>    XGCValues values;
>>    GC maingc=XCreateGC(dpy, drawable, 0 ,&values);
>>    XSetForeground(dpy, maingc, c1.pixel);     
>> XDrawString(dpy,drawable, maingc, 20, 50, "test",4);
>>    pglXSwapBuffers(dpy, drawable); }
> It might work better to put the XDrawString() call after the 
> SwapBuffers().
> Also, you may need a glXWaitGL() call between them.
> -Brian
now I have tryed with
 pglXSwapBuffers(dpy, drawable);
    XDrawString(dpy,drawable, maingc, 20, 50, "test",4);
the only thing that this causes are lower framerates but teh flickering 
isn't gone

More information about the xorg mailing list