Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Draw a sprite on root window  (Read 3995 times)

0 Members and 2 Guests are viewing this topic.

dayday

  • Newbie
  • *
  • Posts: 3
    • View Profile
Draw a sprite on root window
« on: August 01, 2011, 07:24:57 pm »
Hello guys,

I am currently trying to draw sprites on the OS root window (either Windows or Linux) and I'm wondering if this is possible using SFML?

On linux, according to the tutorial on X11 integration (http://www.sfml-dev.org/tutorials/1.6/graphics-x11.php), it seems that sf::RenderWindow can be created with a Window object. And then we can call the Draw method.

So I tried with the X11 root window but it doesn't seems to work. Is it normal, or am I doing something wrong?

The goal is actually to replace mouse icon with some non-standard icons.

Here is the code I tried:

Code: [Select]

// Get root window
Display* Disp = XOpenDisplay(NULL);
int Screen = DefaultScreen(Disp);
Window RootWindow = XRootWindow(Disp, Screen);

// Create sfml render object with the root window
sf::RenderWindow SFMLView(RootWindow);

// Draw a sprite
SFMLView.Draw(sf::Shape::Circle(50, 50, 50, sf::Color(255, 0, 0)));

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Draw a sprite on root window
« Reply #1 on: August 01, 2011, 08:24:04 pm »
The desktop/root window is usually a special one and you can't draw to it directly like this. I don't know if it's possible at all.
Laurent Gomila - SFML developer

dayday

  • Newbie
  • *
  • Posts: 3
    • View Profile
Draw a sprite on root window
« Reply #2 on: August 02, 2011, 08:51:12 pm »
Thanks for answer.

I'm using Ubuntu and I found that Gnome explorer, Nautilus, creates its own windows above the X root window.

It seems that some guys have created some C functions to retrieves Gnome or KDE dektop Window, to draw on it. See this http://stackoverflow.com/questions/2288456/using-desktop-as-canvas-on-linux for more information.

I'm currently trying to use these functions to draw on Gnome. I'll put the solution here if I find something working.

By the way Laurent, SFML is a very nice library, useful, and well designed. I always try to adopt a design as clean as yours in SFML. o)

 

anything