LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   XCB, XLib and X extensions (https://www.linuxquestions.org/questions/programming-9/xcb-xlib-and-x-extensions-451000/)

orhun 06-02-2006 03:08 PM

XCB, XLib and X extensions
 
Hi,

I am trying to learn XCB (xcb.freedesktop.org), but due to lack of tutorials and examples I am forced to study XLib as well. Although I am done with the simple stuff, I have several problems.
The most important one (at the moment) is the flicker. X Extensions might have the solutions I need but, I can not seem to find a decent tutorial for (or even simple introduction to) specific X extensions, other than the man pages. Currently I am interested in XRender and XDBE(double buffer extension).
It looks like GTK, Qt etc are using XRender so I can study those(I am trying to figure out how they are doing flicker free drawing, well almost:), but for XDBE it is almost impossible (at least to me) to find information about it. It seems like no one is using it. Does any one know anything about XDBE? And why is its usage so limited?

paulsm4 06-04-2006 12:27 AM

Hi -

I'm not sure what your question is.

Double buffering is indeed a good way to take care of "flicker" in animations. There are plenty of good web links and documentation on how to use Xlib's DBE, most X servers include DBE as a standard extension (you can use the command "xdpyinfo|less" to check yours), and it's easy to get DBE support if your server doesn't already have it. The "gotcha" is, if you code your app to require DBE, to make sure that all your users' X11 servers also have DBE support.

I happen to like Xlib, but I'm not sure it's the best programming interface to start with. It's definitely not the best tool for all jobs (Many jobs: yes. All jobs: no.)

You might also wish to explore Gtk+ 2.0 and Qt (both or which you mentioned), SDL and OpenGL (to name just a few). Most have a wealth of sample code, tutorials, and mail groups available to help you.

Good luck .. PSM

orhun 06-04-2006 10:37 AM

Thanks.

Quote:

I'm not sure what your question is.
Well, there wasn't a specific question I guess.

Quote:

Double buffering is indeed a good way to take care of "flicker" in animations. There are plenty of good web links and documentation on how to use Xlib's DBE, most X servers include DBE as a standard extension (you can use the command "xdpyinfo|less" to check yours), and it's easy to get DBE support if your server doesn't already have it. The "gotcha" is, if you code your app to require DBE, to make sure that all your users' X11 servers also have DBE support.
My main problem is I can not seem to find those XDBE and XRender tutorials you mention. Moreover, since GTK, QT and SDL do not use XDBE, it made a little reluctant even to try it. Not able to find anywhere on the net about the pros and cons for XDBE doesn't help either. I expect to find such information for any widely used library. Maybe I am missing something. Perhaps I am not good at googling as much as I believe. :)

Quote:

I happen to like Xlib, but I'm not sure it's the best programming interface to start with. It's definitely not the best tool for all jobs (Many jobs: yes. All jobs: no.)
I completely agree with this statement. I already decided XLib(and/or XCB) is the technology I need to utilize but, it's its extensions I can not seem to find enough information. I need others' experiences so that I can at least make an informed discussion on how to proceed, especially given the lack of my knowledge on XLib and XCB.

So if you happen to know any XRender and XDBE tutorials, help me.

paulsm4 06-04-2006 10:18 PM

Hi -

1. I was hoping to find a good example in my library that I could cut/paste for you but, unfortunately, I don't have anything.

For whatever it's worth, this is an excellent book with TONS of sample code.:

Professional Graphics Programming in the X Window System
Eric F. Johnson, Kevin Reichard
MIS Press, 1993; ISBN 1-55828-255-6
http://www.amazon.com

It's been out-of-print for over 10 years, but you can still get used copies from Amazon for as little as $5.00 - $10.00 (USD). If you're genuinely serious about learning Xlib, I think it would definitely be a very, very good investment.

And just FYI, all of Chap 25 is devoted to Double Buffering (including complete sample code).

2. This is another excellent Xlib programming resource, and it, too has a double-buffering example:

http://www.rahul.net/kenton/colormap.html#DoubleBuf

3. Neither Johnson nor Kenton use XDBE per se.

They use a (relatively straightforward) technique where they allocate different Xlib color planes, and then simply alternate between one and the other planes.

When I googled for XDBE code, I got the same results you did: nothing! These two links are the best I was able to find:
http://www.xfree86.org/current/dbelib.pdf
http://publib.boulder.ibm.com/infoce...ext_buffer.htm

4. The intent of my original post, however, was actually to *dissuade* you from trying Xlib for this particular project. I get a strong sense you might be better off with a higher-level library. One that'll do double-buffering (and a lot more!) for you automatically.

You mentioned GTK+ 2.0 and Qt; I added OpenGL and SDL. Any of these four would be a good choice.

I resisted suggesting too many alternatives, but I'd really like to add XForms (http://www.york.ac.uk/services/cserv...ics/xforms.htm) and FLTK (http://http://www.fltk.org/) to the list.

And in particular, I think you might enjoy this article in this month;s edition of "Linux Journal" (most of this month's issue is devoted to "Ruby"; it should be available on most news stands):

"Under-Ice Sonar Visualization", Richard R. Shell, Garner C. Bishop and Douglas B. Maxwell
http://www.linuxjournal.com

'Hope that helps .. and good luck!

Your .. PSM


All times are GMT -5. The time now is 09:26 PM.