• Advertisement

Linux graphic API?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm a beginner to linux and I want to create my own graphical application, but I'm not sure what to use. I don't want to use any graphical environment like KDE or Gnome, I want to create a stand-alone application which will be launched from the console. Some requirements for my application would be to be able to use a resolution ranging from something like 800*600 to 1280*960, in 16/24 bits colors. It would need to work with C++. So, what should I look for to get started? I think I'll need to work with the X System, am I right? Thanks

Share this post

Share on other sites
Advertisement
SDL/OpenGL - requires X
SVGAlib - console

Share this post

Share on other sites
I don't think VGALib is what I want since it probably don't allow big resolutions and lot of colors..

OpenGL would be an idea, but, how would I initialize all the required settings and set up the video mode?

Share this post

Share on other sites
You could also look into the framebuffer.

Share this post

Share on other sites
You can use SDL to cover the platform specific stuff for you. In other words, you use SDL to get a window up (and handle input/sound/etc. if you want), and use OpenGL for rendering. I'm generalizing, of course.

For details:
SDL

About SVGAlib, The only thing I know about it is that it was used to port Quake to linux. Not sure exactly what it's capable of though.

Share this post

Share on other sites
Quote:
 Original post by HedosI don't think VGALib is what I want since it probably don't allow big resolutions and lot of colors..

The 'S' in 'SVGALib' is significant for this very reason...

Share this post

Share on other sites
Quote:
Original post by Doc
Quote:
 Original post by HedosI don't think VGALib is what I want since it probably don't allow big resolutions and lot of colors..

The 'S' in 'SVGALib' is significant for this very reason...

Does SVGALib run well on most number of modern video cards? I've never looked at it again since I met X.

OP: You may want to google for xlib if making your app X based is an option. It's pretty hard, specially the color management. You're warned.

Nice looking fonts are also a big issue. You may need to google for freetype2 too.

Share this post

Share on other sites
Quote:
 Original post by ArkainiumSDL/OpenGL - requires X

Not quite true. SDL apps can run in a framebuffer console as well. I even managed to get Alpha Centauri running in the framebuffer, which I doubt Loki Games had ever considered. SDL might support some other non-x drivers as well but www.libsdl.org seems to be down so I can't check ATM.

Share this post

Share on other sites
Stay away from SVGALib. It requires SUID executables, which is obviously bad, and it's just way out of date.

The two lowlevel ways to access graphics that can be taken seriously are X and framebuffer. However, as others have pointed out, you should really use SDL - which supports both (and more) - unless a) you're a masochist or b) you really are interested in the inner workings of the operating system (come to think of it, that's really the same as option (a) ;)).

cu,
Prefect

Share this post

Share on other sites
Ooops, I didn't know the difference between SVGA and VGA.
Well, anyway, it looks out-dated for sure.
SDL might be a good idea, if it can run from the console as some of you have said, it would be perfect.

So now, I would have to decide to use SDL with X or the framebuffer?
What are the major differences between the two? Any pro/con for each choice?

Share this post

Share on other sites
Except for special purposes, ignore stuff like svgalib and framebuffer - they're really more suited to embedded systems and aren't generally available and/or usable on desktops.

You really want something which works in X - this means that you have either

- Use Xlib directly (not pretty) - with or without OpenGL
- SDL - lets you do limited software rendering into a window or fullscreen in X
- SDL+ OpenGL - hardware rendering, SDL hides the Xlib mess for you (and identical code should work on Win32)
- Use some other library for instance Allegro or GGI

You will be able to launch the app from the command line, if you do so within an X environment already.

As a Linux user myself, I wouldn't generally consider making a game which is not portable to Windows, at least ultimately, as it vastly decreases the number of people who can play it. If you use a library which works on Win32 as well, you can probably port it later with a minimum of fuss (assuming you don't use any other (non-gfx related) Linux-specific stuff).

Mark

Share this post

Share on other sites
Quote:
 So now, I would have to decide to use SDL with X or the framebuffer?What are the major differences between the two? Any pro/con for each choice?

Use SDL. It's available on most every platform and it has a small and well-documented API. Compare that to direct framebuffer manipulation which results in lots of platform dependent code.

Share this post

Share on other sites
Thanks a lot guys, SDL looks like the way to go!

Share this post

Share on other sites
At least on my installation of SDL, it will use X automatically if X is started, and the framebuffer if I run the SDL app in text mode.

Share this post

Share on other sites
I can MAYBE understand why framebuffer would be considered an option in a thread like this, but @#$#!$!@ING SVGALIB!???

ARE YOU FREAKING INSANE?

This is a library that's designed to let you (OMG!) use the incredible resolution of 640x480x256 colors!!! (and up, but this is what it's designed for) Let's not also mention that your silly little game must run as root (BAM your system is hacked for the 12971287 things that you don't know about that you must never do with code running as root). Oh and 3d? You're silly! Computers aren't fast enough to render 3d! LOL Alpha blending LOL!

Share this post

Share on other sites
Quote:
 Original post by C-JunkieARE YOU FREAKING INSANE?

We are all programmers here, but you really need to learn to lay off the sugar, you sound like you are going to kill something :-P

Share this post

Share on other sites
It gets more attention than "svgalib is obsolete."

Therefore, more people remember, and they never commit this sin ever again.

svgalib... sheesh

Share this post

Share on other sites
No one mentions clanlib, or allegro? Shame on you people for not letting him know about more possibilities. :p

Share this post

Share on other sites
I'm using SDL. I've programmed C++ for at least 8 years and I can say it's a good way to go. Even if you just want a windows and a framebuffer, or in our case, open gl, it's pretty good and works everywhere.

Not to mention platform independence which is quite nice :)

I just wanna put SDL in the spotlight it deserves...

Albert

Share this post

Share on other sites
X and the framebuffer are good. Keep in mind that you can also use the DGA 2.0 driver, which uses hardware for graphics acceleration.

http://www.linuxdevcenter.com/pub/a/linux/2003/08/07/sdl_anim.html?page=1

Using the DGA might not be the best idea if you plan on using pixel-perfect collision detection though, as individual pixel access is still relatively slow. Or, perhaps, you can wait until the glSDL backend is integrated within SDL.

Share this post

Share on other sites

• Advertisement
• Advertisement
• Popular Tags

• Advertisement
• Popular Now

• 9
• 48
• 11
• 17
• 11
• Advertisement