#### Archived

This topic is now archived and is closed to further replies.

# Quality of input + graphics under linux

This topic is 6208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello Linux game programmers, I wonder about porting a simple 2d engine from windows to linux. I''ve got some questions: 1. Can I get keypresses and releases from any key under linux ? I mean not only getting a char but getting a ''key 23 is pressed down/released'' message ? How easy is it to access every gamepad/joystick, what about USB joystick drivers ? Are more than 2 joystick supported, and is every button/key avaiable ? 2. How much slower is the gfx ? I think this shouldn''t be a matter in 2d but it would be great to know possible problems. Are there any things I should avoid ? 3. Are there ide''s like MS Visual Studio ? Or do I have to use emacs, vi, etc. ? If there are some which would you recommend ? As you see I don''t know too much about Linux, I''m just starting to get comfortable.

##### Share on other sites
Here are some partial answers. I hope some more come along.

1. Yes, you can. The question is how you do it. I personally use SDL, which works nicely and works under Windows, MacOSX (and older versions unofficially), Linux, FreeBSD, and possibly other platforms... I''m sure you can get keypresses directly from X, though i''m not the one to axe about that.

2. In general, not much slower, though it depends on any number of things, including the quality of the driver on the video card, program threading, god knows what else.

3. Hmm... Well, there''s Code Warrior for Linux, though i haven''t heard much good about that version. I don''t really know, because i personally use vim, ddd, make, and all that stuff.

-ben.c

##### Share on other sites
2/ for 3d it depends very much on the card nvidia cards are not much slower and in some cases a bit quicker but for other cards performance is generally about 50-80% of windows.
3/ for the kde environment ive used www.kdevelop.org which is quite good

http://members.xoom.com/myBollux

##### Share on other sites
As far as I know, 3Dfx Glide is faster in Linux than in Windows...

- JQ
Infiltration: Losing Ground
"You just don''t understand. Guys have to be immature and stupid. It''s some biological thing. It helps us hunt and gather and stuff." -Nazrix

##### Share on other sites
Hi,
1) You can get scancodes for mouse,keyboard and joystick in linux using SDL, svgalib etc
2) Opengl, 3dfx are more dependent on your card.
3) Try kdevelop for an IDE.

Regarding MFC - there are no MFC stuffs in Linux. Something similar - try fluid. Comes with fltk.

##### Share on other sites
Actually, Qt more or less fills an MFC-like role. If you''re using KDE (which I highly recommen), you''re going to use the KDE classes which are based on Qt. They aren''t exactly MFC-alike, but they have the same role.
BTW, Qt OOP is very clever (it needs an additional MOC-compiler though - don''t worry, everything''s C++), and beats MFC any time.

cu,
Prefect

---
Sanity is the trademark of a weak mind.

##### Share on other sites
I wouldn''t rely on the existence of KDE (or just Qt) on the system when writing games, if it can be avoided. I don''t really suggest it with many applications, but games less so. The Linux gaming audience is small enough as is, no need to cut it another 60% (or whatever).

Don''t worry though, i feel the same way about GNOME.

-ben.c

##### Share on other sites

To get keypresses or keyreleases (aka key board events)
it depends on what kind of application you are writing.
You have three choices; Xlib, ETI, or raw terminal.

I''m going to assume Xlib, since that is more graphical
based and most Linux games use that. In which case you will
need to look at ''man XNextEvent'' to fetch the next event
(also look at man XPending'' to check if there is a next event
instead of blocking. Then you need to handle that event,
in which case you need to check if its type. For example

XEvent event;
if(event.type == KeyPress)

Look at man XEvent'' and man XKeyEvent'' for details on
this structure.

Next you will need to tie in the keycode'' that you get
from the above structure with a keysym'' the keysym
name is fetched with first converting the keycode
to keysym using XLookupKeysym() then once you
have the keysym, use XKeysymToString() to convert it to
a string.

Now you need a list of string names to relate to ASCII
characters. For example you can compare the string returned
by XKeysymToString() to "greater" which would be the ''<''
character.

Look in the keysym header files in /usr/include/X11/
for a table. Note that the names returned by XKeysymToString()
are basically those of the #defined values without
the prefix.

##### Share on other sites

Linux supports most analog/digital joysticks
versions of Linux may support USB joysticks.

In any case, Linux has a wrapper for Joystick
device in the form of event IO (similar to Xlib).
You will need to use libjsw for this, see
http://wolfpack.twu.net/libjsw

man JSIntro'' to see the tutorial about its API.

##### Share on other sites

When you reffer to gfx, is that a typo reffering
to glx? or do you mean `graphics''?

Graphics under Linux/X is a tad slower compared to
Windows (in my experiance) however the slowness is at most,
df 0.00001 fps differance so its minimal.

Linux is always sync''ed processing (unless you use threading) however Windows'' glw is threaded by default.

glx is basically a wrapper just like glw, however in my
porting experiances with two apps on the same comptuer,
the Windows version runs much faster in graphics generation
and initialization however in normal runtime performance
is roughly the same.

##### Share on other sites

There are two ways to look at this question,
Linux is virtually one big development studio.

Most coders open a few XTerms with pico or emacs (for
the obscenely geeky) with one more XTerm to type ''make''
over and over in.

If you want something similar to MSDev then try
CodeCommander, aka Latte, aka Glimmer.
This program has under gone a ton of name changes so I don''t
know for sure what it is called today.

You can check on www.freshmeat.net and do a search
for ''glimmer'' (it''s latest name).

##### Share on other sites
Re: Shelrem

I believe cmdkeen was trying to port a graphics engine,
not a game? In which case I wouldn''t recommend SDL
otherwise you''d be making a engine ontop of an engine.

But SDL is a good start if you want to write a game
for Linux to get yer feet wet.

Also since speed and low-levelness is an issue, you
might want to stick to Xlib and glX for this one.

##### Share on other sites
There''s been a lot of mention about SDL''s and toolkits,
but that might not be the best approach for porting
an engine.

Because if you write an engine that is depending on
a toolkit or another engine, that will basically produce
an extra level of redundancy.

QT is a widget set, geared more towards office
applications rather than games. I definatly don''t recommend
any widget set used for a game or game engine.

SDL is a good start to learn how to code a game under Linux
but once you get ready to port your game engine, I strongly
suggest using direct Xlib instead of any higher level
languages. You''ll want this to be as low-level as you can
get.

##### Share on other sites
Nobody recommended the use of Qt or KDE for your game, just as base for a development IDE.

I really have to disagree about the SDL thing. First of all, Xlib''s a bitch, and trying to learn it is damn hard. Second, using SDL just makes everything so much easier to port. You don''t have to write the low-level part of your game twice or even more times.
SDL also runs on more than just Xlib. Though I don''t know how well it works, it''s intended to run with fbs, SVGALib, GGI, and some more as well. You won''t want to care about low-level support for all of these APIs.
And SDL really isn''t slow. Sure, there''s some overhead included, but if you take care of clipping etc... yourself it''s more or less reduced to one or two pointer dereferencings.

cu,
Prefect

---
Sanity is the trademark of a weak mind.

##### Share on other sites
Sorry, I misread the referance to QT, since it being
a widget set I got the signal that you wanted to use
that as a basis for the graphics engine.

I really don''t see QT being used as a program to be an
integrated development suite so I presumed it was being
used as part of the program.

As for Xlib vs SDL, I strongly recommend X11 over SDL
over most low-level situations. The original poster
wanted to port a graphics engine. Again if you used SDL
your going to end up with a engine ontop of an engine.

Xlib is a more older and proven technology, it''s also
more documented compared to SDL. Also, SDL limits
the use of UNIX specific features. But that wouldn''t
matter much to a graphics engine. Again you want to
port a graphics engine, not write a game.