🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

X programming... how???

Started by
6 comments, last by klems 16 years, 3 months ago
After ive been toying with managed DirectX and some OpenGL on Windows, ive decided i wanned to try out OpenGL on Linux. Ive done some small amount of C programming in Linux, during a OS curse and came to like it. I loved how the man pages was right at hand and the rest you could google easy enough. Now during my OpenGL experience on Windows i used GLUT, ive decided i rather wanned to try out pure OpenGL and X11 on Linux without any wrapper code(GLUT). Ive looked at some of the GLX examples that comes with Mesa and the code aint hard to follow. Much of it looks like the stuff you see from doing win32 programming with regard to creating windows and event loops etc. My problem comes when i get stuck. I find its hard to get info from google. Seems not alot of people are really programming X applications. I always seem to find a ton of info for .NET and C++ on windows or Java for that sake. Also sure you have man pages for much of the stuff found in Xlib but its just hard when you dont know what to look for. Maybe i got spoiled starting out with Java with the easy html API documentation SUN provided with it and ample examples etc. All ive found for X11 is this site http://www.xfree86.org/4.1.0/ it have a section 3 with lib functions, its ok but severealy lacking in many aspects. As a example i wanned to try to get some keybord input, but have now been looking for 30 min on the net without really finding anything on how the different keycodes from XEvent and XKeyEvent map to the keybord. In general most open source documentaion is lacking, Its ok ofc since its free and i understand some very talented people put in alot of time and effort, so who am i to complain. I just wish they would spend more time on the documentation since it makes it so much easier to appriciate there work. Well sorry for this rant. Ill think ill have to look up some books on amazon or something and maybe its also a bit ambitious expecting to learn X from the internet and man pages alone. But a simple window and some key input for some OpenGL shouldnt be that daunting. So what i really want to ask is if anyone got any tips... how did you get startet on X programming.
Advertisement
Here are some tutorials.

Xlib programming: a short tutorial
Beginner Xlib Tutorial
XLib on wikipedia

If you don't like XLib there is also XCB, I hope it will replace XLib completly
XCB on wikipedia
Thank you Megamoscha.

Alot of good info on those links. I will look into em. Should be enough to get me startet for the simple stuff i need so i can focus on the OpenGL side of things.

Not sure how all that stuff slipped by me usualy im rather competent at finding stuff :)
Hehe, I know what you mean. As I searched a year ago, I used "X Window Programming", "X Server Programming" and the like but didn't find anything. One look at wikipedia pointed me in the right direction.
Unless it's purely for the "pleasure" of learning X programming, I'd strongly advice you to use SDL or some similar library for setting up rendering, input, etc. The reason why information on Xlib is sparse is probably that nobody ever uses it directly, except for the people who write window managers or GUI toolkits.
You are confused or misinformed.

The X Window system is immaculately documented in excruciatingly great detail. I have a shelf of books published decades ago when the X11r4 was first released. Google reveals almost 300 titles to choose from.

Yeah, the docs aren't free. X11 is not free software. Since X11 predates the internet the docs tend to be hardcopy, and shipping and warehousing costs big. Those suckers are not svelte.

That said, few people program in X11 directly, not only because it's a lot of work, bit because your app will taste like ass. Unlike Windows with its centrally-planned economy, Linux distributions offer an entire free market of desktop systems, each with its own look and feel. Most people target one of the more popular ones -- Gnome or KDE -- which require using an appropriate layer on top of X11. The Gnome and KDE frameworks are more directly the equivalent of the Windows API.

If you really want to do X11 directly, well, good luck with that. At least lifting the books will help build upper body strengthy.

Stephen M. Webb
Professional Free Software Developer

Oh, i was under the impression from X.org that X was free since it had alot of stuff about how to submit patches and codestyle and all such stuff that open source usualy have.

I gave SDL a look and it looks good, so i think ill give that a try. Maybe GLUT got me a little scared away from easy to go wrapper code since it was so simplistic.

Thanks for the help all :)
Quote: Original post by Lio
Oh, i was under the impression from X.org that X was free since it had alot of stuff about how to submit patches and codestyle and all such stuff that open source usualy have.
X.org is free, though the original implementation of the X window system wasn't.

Quote: Original post by Lio
I gave SDL a look and it looks good, so i think ill give that a try. Maybe GLUT got me a little scared away from easy to go wrapper code since it was so simplistic.
I don't know anything about GLUT to compare with, but SDL is good enough that it's used by a whole crapload of games, both free and commercial. Among its highlights are Battle for Wesnoth, Neverwinter Nights, Second Life, the Unreal Tournament games and Quake IV.

This topic is closed to new replies.

Advertisement