Thread: Need help with basic graphics

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    4

    Need help with basic graphics

    I need to create a small application that should display graphical elements on top of my desktop without interfering with it. But I don't really know where to turn to.When the application is closed, all the graphical elements it created should be removed. Basically I want to place an overlayed canvas on top of my desktop.Is there any easy way to do this? Where should I look into? xlib?I haven't program in C/C++ since my introductory programming courses at university, more than ten years ago. I still remember most of it, but my experience is limited.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You can use xlib for that; I don't know how much more (or less) work that will be than using a GUI library such as gtk. The only documentation for xlib I know of is the man pages for the API, and this:

    http://tronche.com/gui/x/xlib/

    If you can get what you want out of that, you're set. If not, maybe check out gtk.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    If the 'elements' are not in any way user interface controls and widgets, you are better off with using something like SFML. Its drawing API is pretty easy to learn.
    Also, I wouldn't recommend Xlib programming, unless you can devote a substantial time learning about its idiosyncrasies. It is much easier to learn Qt, gtk, fltk..etc for making GUI `s.

  4. #4
    Registered User
    Join Date
    Feb 2012
    Posts
    4
    I have moderate knowledge of graphical toolkits because I've used them in a couple of occasions in the past. But I never got proficient in any as I only used them a bit.To this small project, if possible, I would prefer c and xlib for no logical reason I can think of... maybe curiosity.Regardless my choice, I don't know how o do this using any library, so I guess I could use whatever works.Could anybody be more specific with the docs? After reading large amounts of xlib documentation I still don't know how to get out of the window realm. How do I draw a line on the screen without opening a new window?

  5. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by cico View Post
    I have moderate knowledge of graphical toolkits because I've used them in a couple of occasions in the past. But I never got proficient in any as I only used them a bit.To this small project, if possible, I would prefer c and xlib for no logical reason I can think of... maybe curiosity.Regardless my choice, I don't know how o do this using any library, so I guess I could use whatever works.Could anybody be more specific with the docs? After reading large amounts of xlib documentation I still don't know how to get out of the window realm. How do I draw a line on the screen without opening a new window?
    I've never done anything graphical with X, but I'm sure you can control the opacity of a window*. The background screen is actually the root window, and you may be able to do things with that, but a quick google implies to me that is a bad idea because some DE's (inc. gnome) overlay that with their own "root window".

    The easiest way would probably be to use a shaped window, if you google "xlib shaped window" you'll find clues. You can also place pixmaps on the screen without a window, but of course, those are quadrilateral shapes.

    * however, that may affect anything drawn in the window too, lol. I think apps that use transparency in their background actually acquire a corresponding area pixmap of the root window and draw that in to mimic transparency, which is why you generally do not see the window behind it, if any -- you see all the way thru to the background.
    Last edited by MK27; 02-18-2012 at 11:02 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    I know I'm late to the party on this one, but I'll just leave this here for later.

    These sorts of applications are variously named, but you'll find "widget", "gadget", and "screenlet" used fairly often in tutorials and libraries.

    If you want to provide a familiar "look and feel" across "x11" managers you'll have to use multiple support libraries--specifically those provided by the manager. Gnome and KDE have very different provisions for this and without tweaking for each one you'll get nice to ugly results.

    I strongly suggest using a library that has already done this fiddly crap for you. I'm sure you an find others, but I've used "screenlets". Properly configured it gives nice results across the board, but I'll freely admit that my little widget looked way better on KDE after a kindly soul dropped some source on me to do something similar directly with "KDE" libraries.

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Basic PC graphics
    By A34Chris in forum Game Programming
    Replies: 18
    Last Post: 11-09-2011, 02:25 PM
  2. Basic Graphics in C++
    By JCML in forum C++ Programming
    Replies: 1
    Last Post: 09-28-2010, 06:32 PM
  3. Best way of drawing basic graphics
    By Jelte in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2010, 05:15 PM
  4. Basic Graphics Tutorials ?
    By Syme in forum Game Programming
    Replies: 2
    Last Post: 12-07-2001, 09:00 PM
  5. basic graphics!!! I'm stressing here!!!
    By CumQuaT in forum C++ Programming
    Replies: 5
    Last Post: 09-17-2001, 11:26 AM