Advertisement

X Windows

Started by May 14, 2003 05:41 AM
9 comments, last by BIOSME 21 years, 8 months ago
Hello, I am a newbie Linux programmer. I''m planning to program a simple game/graphics app on linux that runs from the text prompt - as the case with DOS. Is it possible to make the application start the X server or I must use startx and switch to one of the available windowing desktops (GNOME, KDE, ...)?
Is there a sane reason why you can''t just write a normal X application? You should _never_ even think of doing something like this (starting the X server yourself etc...), as it just gets you into too much trouble.

Remember, even if you want to use stdin/stdout in an X application for some reason, you could just tell people to run the application from an xterm/konsole/whatever window.

cu,
Prefect
Widelands - laid back, free software strategy
Advertisement
I know I have to use X Windows API, but not on top of a wrapper (GNOME/KDE). How do I initiate graphics mode for use with OpenGL without having to start a window manager?

quote:
Original post by BIOSME
I know I have to use X Windows API, but not on top of a wrapper (GNOME/KDE). How do I initiate graphics mode for use with OpenGL without having to start a window manager?




Your program doesn''t need to start X. Period. You should be able to use the X Windows API if Gnome/KDE are running or not. The window managers do not prevent you from using a different toolkit (or just the X API) instead of their own toolkit.
Unfortunatly I''m not much of a GUI programming in linux yet and I have no clue how to get opengl started up... sorry.
Shoot Pixels Not People
quote:
Original post by BIOSME
I know I have to use X Windows API, but not on top of a wrapper (GNOME/KDE). How do I initiate graphics mode for use with OpenGL without having to start a window manager?



If the X server is already running, you simply call XOpenDisplay() to connect to it.

Once you have the display connection, you can issue X and GLX calls as required (I guess you could start with glXChooseVisual(), XCreateWindow() and glXCreateContext().

Good luck,

navigator


[edited by - navigator on May 14, 2003 9:03:46 AM]
---Never trust a Troglotroll.
Technically speaking if there is no WM then you get singular access control to the X server.

For example, you can completely and totally accurately have a program that runs X. Not startx, nothing except the core X server.

It then connects to that server as the -only client- and creates one single base level window that uses the entire screen.

Anything you want to do can then be done in that window.

There are people who will tell you this is EVIL and you should never do it... but quite franky it''s just a matter of oppinion. It is quite true that doing this DOES result in some (MINOR) performance improvements.

The only major bonus is not having to worry about the stupidity of your WM.

Note: In the old world of X this was the only way to dynamically set the X server depth and resolution. Recent version let you do it at run time through extensions so there''s no need.
Advertisement
I am getting happier than before. How do I run X server from within my program?
Is there any tutorial/docs for plain X Windows programming?
Thanks.
actually, you can''t start X from inside a program that I know of, although you could write a shell script.

xlib tutorials are thin on the ground, but check out NeHe. Some of his tuts are ported to glx.
quote:
Original post by BIOSME
I am getting happier than before.
Interesting...
quote:
How do I run X server from within my program?
You do not.
quote:

Is there any tutorial/docs for plain X Windows programming?
Google turns up many, and I''m not gonna do that for you.

but might I suggest SDL instead of xlib? libsdl.org

quote:
Original post by BIOSME
Is there any tutorial/docs for plain X Windows programming?
Thanks.



Well, if you have the appropriate devel packages installed (X11-devel or something like that depending on your distro),
you should have manpages for all X functions. The oficial API documentation (both PDFs and HTMLs) can be downloaded at ftp.xfree86.org.

Good Luck,

navigator

[edited by - navigator on May 15, 2003 3:58:10 AM]
---Never trust a Troglotroll.

This topic is closed to new replies.

Advertisement