Reputation: 1
I would like to add particular effects directly on the screen (first on ubuntu 12.04), for example i would like to code a c++ deamon that would be able (for example) to blur all my screen in real-time. One should be able to move his mouse, read text, browse the internet but everything stills blurry. I've read that the task should be to access and modify the screenbuffer. Is that true ? Am I looking the wrong way using OpenGL ?
Upvotes: 0
Views: 417
Reputation: 162164
I would like to add particular effects directly on the screen (first on ubuntu 12.04), for example i would like to code a c++ deamon that would be able (for example) to blur all my screen in real-time. One should be able to move his mouse, read text, browse the internet but everything stills blurry.
This is called a composition effect and is usually implemented as a plugin for the compositor
I've read that the task should be to access and modify the screenbuffer.
On a modern OS you do not have direct access to the screenbuffer. So this won't work.
Is that true?
No. Or actually very inaccurate.
Am I looking the wrong way using OpenGL?
No, you're looking into the right direction.
Let me explain: Back in the old days your screen consisted of a single large framebuffer, which all applications shared. But to protect the applications from each other they can not directly access that framebuffer. Instead they use the graphics/windowing system, which in the case of Linux traditionally has been X11 (there's another system in development right now, but frankly, I deeply detest its design), GDI on Windows and Quartz on MacOS X.
The graphics system took care that drawing operations to a window would end up at the right place on the screenbuffer and would be properly clipped and occluded by the window geometry and other windows on the screen. Whenever a window was resized, or previously occluded parts of it got exposed a message was sent to redraw those portions. Just moving a window could be implemented by intrabuffer bitblitting.
With the advent of modern GPUs and their local framebuffer memory model this old way of managing windows became an anachronism. Now you could give each window its very own, independent framebuffer. Only if a window was resized a forced redraw becomes necessary; there are no longer occlusions that would damage a windows content.
But for this model to work you need some program to take those individual, separate framebuffers containing the window contents and composit them into a single image on the screenbuffer, presented to the user. This is done by a compositor. And because the composition may happen with whatever drawing APIs are available, you can also use OpenGL for it and apply crazy effects while doing so.
Upvotes: 1
Reputation: 181785
You'll need to use a compositing manager, such as Compiz, which reroutes all drawing through OpenGL and allows you to do all sorts of fancy things.
For example, the one that ships with Ubuntu can make raindrops fall on your screen, which can be turned on via the Compiz settings manager.
If you are new to OpenGL, though, I wouldn't recommend diving into this. Learn about basic draw calls first, then tackle shaders. And you might also need to learn about X.
Upvotes: 2