Kodi Community Forum
Where to start with screeensaver developing for XBMC? - Printable Version

+- Kodi Community Forum (http://forum.kodi.tv)
+-- Forum: Development (/forumdisplay.php?fid=32)
+--- Forum: Visualization and Screensaver Development (/forumdisplay.php?fid=38)
+--- Thread: Where to start with screeensaver developing for XBMC? (/showthread.php?tid=84170)



Where to start with screeensaver developing for XBMC? - eyes - 2010-10-27 17:18

Hi everybody,
I'm new in this forum and also developing for xbmc.

I would like to develop a screen-saver, something easy, something like the slide show of images.

Could someone tell me how can I start? which documents do I have to read? which examples should I review? If there is a template to develop. Confused

Any help or comment will be welcome.

thanks in advance. Nod


- spiff - 2010-10-28 09:33

actually the builtins are horrid examples. atm we have very few screensavers - the rsxs based ones for linux only from the looks of it.


- eyes - 2010-10-28 10:35

Thanks, but there is a mail list or something where I can ask from the first beginning how to start to program/develop a new screensaver, addon, or any other module for xbmc


- Ebbo - 2010-10-28 10:49

I'm also interested in developing a new slideshow.


- spiff - 2010-10-28 12:30

unfortunately it's to a large extent monkey see, monkey do (i.e. you have to read it from sources). the interface is given in xbmc/addons/ScreenSaver.h/cpp and xbmc/addons/include/xbmc_scr*.h

the rsxs ones are the only example as i said, see xbmc/screensavers/rsxs-0.9/src/euphoria/euphoria.cc for instance.

finally you have the add-on definition bits, see addons/screensaver.rsxs.euphoria/addon.xml


- phymata - 2011-02-03 05:59

@eyes
I have the same question. Did you ever come across any good resources?


- outfoxer - 2011-04-05 12:53

Same question, where to start?
I want just simple text screensaver with quotes loaded from forismatic.com API.


- derossi - 2011-04-24 20:09

spiff Wrote:unfortunately it's to a large extent monkey see, monkey do (i.e. you have to read it from sources). the interface is given in xbmc/addons/ScreenSaver.h/cpp and xbmc/addons/include/xbmc_scr*.h

the rsxs ones are the only example as i said, see xbmc/screensavers/rsxs-0.9/src/euphoria/euphoria.cc for instance.l

I've been going down this path with some progress, but it's slow. My short-term objective is to produce a minimal screensaver with source and documentation that we can all use as a starting point. At the moment, I have code compiling, loading, and running but it doesn't do anything yet except clear the screen to a solid color.

As a test case, I'm using the small classic gears example from the OpenGL docs.

My current problem is that I don't know what OpenGL state I'm allowed to mess with and what I need to save/restore so I don't mess up XBMC. If I run the gears init() function without changes, then when my screensaver stops I'm left with a black screen. XBMC is functional and responds to the keyboard, but it can't draw its GUI. Any quick answers about how to leave things in a state that XBMC needs would be appreciated.


- bobo1on1 - 2011-04-27 20:27

Can you give a link to the code you're trying to port?


- derossi - 2011-04-28 07:58

bobo1on1 Wrote:Can you give a link to the code you're trying to port?

The code is gears.c here: http://www.opengl.org/resources/code/samples/glut_examples/mesademos/mesademos.html

Since I've made further progress, let me go into some more detail--

In Start(), I'm doing this:
Code:
glPushAttrib(GL_ALL_ATTRIB_BITS);
init(); // copied from gears.c; calls gear(...) also from gears.c
This sets some OpenGL state and builds the display lists for the three gear objects.

In Render():
Code:
updateAngle(); // my own small function to make the gears rotate

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glFrustum( ... );
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glTranslatef(0.0, 0.0, -40.0);

draw(); // from gears.c, but glutSwapBuffers() changed to glFlush()

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
And in Stop():
Code:
glPopAttrib();

This actually works (yay!), but leaves some nagging questions:

If I don't include the glPushAttrib() and glPopAttrib() calls, then when the screensaver is stopped, XBMC shows only black screens. It responds to keyboard & mouse, so isn't hung, but its ability to show anything is messed up.

But doing glPushAttrib() in Start() and glPopAttrib() in Stop() seems risky. Assume XBMC someday does:
Code:
glPushAttrib( ... );
pScreensaver->Start();
glPopAttrib();
Then things can get weird. In other words, I'm not guaranteed that
Code:
Start();
while (...) Render();
Stop();
isn't interleaved with XBMC's own calls to change OpenGL state, push/pop attributes, etc.

On the other hand, pushing all the attributes, setting them the way I need them, drawing my screen, and popping all the attributes every time that Render() is called would be nice to avoid if it isn't necessary. In fact, I think that popping all the attributes would release by display lists, and setting those up really should only have to happen once.

But if the rule is that the OpenGL state upon each entry to Render() is arbitrary and must always be set up completely each time, then that would be good to know and document.

A similar but less intrusive questions comes with the projection and modelview matrices. Even if my screensaver is running, I notice that XBMC changes these matrices between calling Start() and calling Render(). At the very least whatever it's doing seems unnecessary since the screensaver occupies the entire screen.

Any input appreciated.


- alindl - 2011-05-22 16:48

could you post the actual files you've got a working version from so we can have a look? I'd like to have a go at getting something better working too...

have you managed to get it installing as an add-on too?


- TREX6662k5 - 2011-06-25 03:37

Ah, any reason why Xbmc can't launch system installed screen savers? I presume this is a legacy area as the Xbox lacked screen savers?

Building and porting screen savers for xbmc is a little excessive when there are plenty of working screensavers out there.

Anyway to replicate the behaviour in python and xbmc.service? Say have a python service in the background that detects inactivity after a user configurable time and runs a user specified (or windows registered) screensaver? That would open up possibilities.


- NotNobody - 2011-06-26 21:49

I will be donating once this functionality is added.


- TREX6662k5 - 2011-07-05 01:56

I'm sure its now possible via a plugin with this commit.
https://github.com/xbmc/xbmc/commit/c16324bdea406c38708423e860cf777d055620b3

We listen for the broadcast and start or kill the screensaver as necessary. Ideally xbmc screensaver should be set to blank to keep cpu usage to a minimum. I'm gona see how far I get with this to get electricsheep working.


RE: Where to start with screeensaver developing for XBMC? - filo_beddo - 2013-01-29 01:22

Dito to this request, I wanted to find some info on creating a screen-saver for XBMC.

I wanted to see if I could knock up something which did the same as this one by Tristan Schmelcher for Ubuntu.

http://randomtristan.blogspot.co.uk/2012/08/removing-image-retention-on-plasma.html
https://github.com/TristanSchmelcher/plasmacleaner

It just mimicks the simple tool found on some Plasma TV's designed to remove image-retention.
It's just a black screen with a 1/3 horizonal white bar which very slowly scrolls over the screen so should be pretty simple to do if I can get a hook into the basics of creating a saver.