XdrawString+double buffer
Brian Paul
brian.paul at tungstengraphics.com
Mon Jul 31 08:40:02 PDT 2006
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
More information about the xorg
mailing list