LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-10-2015, 12:55 PM   #1
multiplex22
Member
 
Registered: Dec 2014
Location: ny, us
Distribution: most
Posts: 56
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
Old 02-10-2015, 02:25 PM   #2
genss
Member
 
Registered: Nov 2013
Posts: 741

Rep: Reputation: Disabled
-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
 
1 members found this post helpful.
Old 02-11-2015, 12:46 AM   #3
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
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.

Last edited by veerain; 02-11-2015 at 11:21 AM.
 
Old 02-11-2015, 10:48 AM   #4
metaschima
Senior Member
 
Registered: Dec 2013
Distribution: Slackware
Posts: 1,982

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
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.
 
Old 02-12-2015, 12:26 AM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,622

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
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
 
1 members found this post helpful.
Old 02-12-2015, 10:19 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,877
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
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
 
Old 02-13-2015, 12:00 PM   #7
multiplex22
Member
 
Registered: Dec 2014
Location: ny, us
Distribution: most
Posts: 56

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
Old 02-13-2015, 12:03 PM   #8
multiplex22
Member
 
Registered: Dec 2014
Location: ny, us
Distribution: most
Posts: 56

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by John VV View Post
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.
 
Old 02-13-2015, 12:04 PM   #9
multiplex22
Member
 
Registered: Dec 2014
Location: ny, us
Distribution: most
Posts: 56

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
Quote:
Originally Posted by veerain View Post
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.
 
Old 02-13-2015, 01:05 PM   #10
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,126

Rep: Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260Reputation: 1260
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
 
Old 03-06-2015, 02:33 PM   #11
multiplex22
Member
 
Registered: Dec 2014
Location: ny, us
Distribution: most
Posts: 56

Original Poster
Blog Entries: 1

Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Graphics Programming lovelylinux Programming 7 04-24-2007 10:32 PM
Graphics programming lovelylinux Fedora 1 04-23-2007 08:05 AM
Graphics Programming on linux using C hazzyb Programming 5 07-15-2005 03:11 PM
how to use mouse in C graphics programming... bastin_gh Programming 5 07-13-2005 11:47 AM
graphics programming with gcc mamta_k Linux - Software 1 06-01-2004 07:28 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration