LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Graphics Programming, New (https://www.linuxquestions.org/questions/programming-9/graphics-programming-new-4175533627/)

multiplex22 02-10-2015 12:55 PM

Graphics Programming, New
 
I would like to know how you can begin on graphics programming in Linux, Desktops. On the text cli only, this is simple by accessing the fb0 file. In Desktop vrrsions there is some other way. I need only help in starting a window and then any simple drawing algorithms for start.

What isnt clear to me after lots of research is how complex a simple window can be. I have Gnome, Kde, X11 distros. I know that GTK exists, but I imagine there is SDL as well.

Do I need X11 installed for a box?
Do I have a lot of dependency issues?
Do I need the GTK toolkit?

Scrutiny is warranted, but hey I am no typical pro.

genss 02-10-2015 02:25 PM

-to open a window in X, you need X :)
-depends on what you use to open a window
-not really

GTK is a toolkit used to make windows and content in them (lots of other stuff got in over the years)
same with QT, EFL etc. (gnome is made on gtk, kde on qt)

SDL was originally for games
it's more or less a set of abstractions used to make a window, draw on/in it etc. (also sound, opengl)
it is very modular and fairly light

or you can just use X directly, as all others come to X in the end (well, theres wayland now)
X also has drawing routines

i haven't dealt with X much, this looks good
http://math.msu.su/~vvb/2course/Bori...ow/xintro.html

the fastest and lightest way to get things on screen under linux (other then using the framebuffer) is by using X shm protocol extensions
http://www.x.org/releases/current/do...proto/shm.html

veerain 02-11-2015 12:46 AM

Quote:

On the text cli only, this is simple by accessing the fb0 file.
Text cli uses ncurses.

Don't do direct X Window programming these days. Also wayland is going to replace X Windows.

Use a tookit like GTK, QT, EFL, SDL, They allow arbitrary drawing canvas.

You can use direct OpenGL (Mesa3D, freeglut) too.

metaschima 02-11-2015 10:48 AM

What kind of graphics programming ?

You want a GUI ? QT, GTK, and many others.

You want to program games or just draw stuff on a screen ? Use SDL2.

John VV 02-12-2015 12:26 AM

all of the above

but QT5 might be winning out on the GTK VS. QT squabble

there is also just x11 and c++
for that have a look at Gmic and the "Cimg.h" library
yes it is a header and a library
http://cimg.sourceforge.net/download.shtml

it is tiny and can do many REALLY COOL things
http://cimg.sourceforge.net/screenshots.shtml
like Tetras in 197 lines of code
http://sourceforge.net/p/cimg/source...les/tetris.cpp

rtmistler 02-12-2015 10:19 AM

All the packages listed thus far I agree with.

Try to use the desktop first, the framebuffer is not always available/accessible and many of these packages, while they "advertise" that they can work with it, ... they do not or it's the old "jump through a flaming hoop doing a spinning backflip" in order to get it working.

At least start with an XWindow environment, design your app, get to know how to do the UI programming.

And if it's a full screen, kiosk type of application; hence you not wanting all the window dressing and menu; remember that there are plenty of options such as running the XServer without a display manager, disabling the screen savers and power management. There are options to accomplish something like that, I do this all the time because framebuffers are difficult, hardware specific, and non-existent with some hardware types. Just my $0.02

multiplex22 02-13-2015 12:00 PM

This all seems reasonable. SDL is probably what I want. I just wanted to know if it can handle GUI. There are many graphic tiers in Linux distros, so I was wondering if SDL can handle the GUI across platforms?

Wouldnt want to get deep into a package dependency scenario. So the answer is something basic, but capable of Desktop interaction. I try to stay away from stuff like ncurses if possible. I can handle most of that on my own.

No game interests yet. Already have all the games I can possibly handle.

So I guess maybe I should check out SDL for now and go down that path. A simple 4 line example would be nice. GTK, X11 sounds a bit too big for me. After seeing how many files are in the usr directory, im kinda discouraged. BASH source code is like 4 megs big for example. Quite an experience.

multiplex22 02-13-2015 12:03 PM

Quote:

Originally Posted by John VV (Post 5315875)
all of the above

but QT5 might be winning out on the GTK VS. QT squabble

there is also just x11 and c++
for that have a look at Gmic and the "Cimg.h" library
yes it is a header and a library
http://cimg.sourceforge.net/download.shtml

it is tiny and can do many REALLY COOL things
http://cimg.sourceforge.net/screenshots.shtml
like Tetras in 197 lines of code
http://sourceforge.net/p/cimg/source...les/tetris.cpp


Hey, this is good stuff. Thanks for the lead.

multiplex22 02-13-2015 12:04 PM

Quote:

Originally Posted by veerain (Post 5315323)
Text cli uses ncurses.

Don't do direct X Window programming these days. Also wayland is going to replace X Windows.

Use a tookit like GTK, QT, EFL, SDL, They allow arbitrary drawing canvas.

You can use direct OpenGL (Mesa3D, freeglut) too.

Still looking into those. Ive done OpenGL before and almost forgot about that.

smallpond 02-13-2015 01:05 PM

You don't say what language you want to write in. Most have several toolkit libraries. Here are a few:
  • perl - PerlTk
  • Java - Swing
  • C++ - wxWidgets

multiplex22 03-06-2015 02:33 PM

Ok, thanks everyone. That sure made it easier. Decided Sdl was it. I have to do everything from scratch, but has all the desktop events I need. Wasnt too hard.


All times are GMT -5. The time now is 11:31 PM.