openframeworks / openframeworks/openFrameworks
Proposed change: expose alpha flags for ofAppEGLWindow
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
Currently the default alpha flag set for a RPi window is DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS
Other options are:
DISPMANX_FLAGS_ALPHA_FROM_SOURCE
DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS
DISPMANX_FLAGS_ALPHA_FIXED_NON_ZERO
DISPMANX_FLAGS_ALPHA_FIXED_EXCEED_0X07
DISPMANX_FLAGS_ALPHA_PREMULT
DISPMANX_FLAGS_ALPHA_MIX
DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS sets all alpha values to the value of settings.eglWindowOpacity (default 255). For example, if settings.eglWindowOpacity is set to 128 and I draw a rectangle with an alpha value of 255 the alpha value will not exceed 128.
The most interesting is DISPMANX_FLAGS_ALPHA_FROM_SOURCE. With settings.eglWindowOpacity set to 0, this allows a totally transparent window but elements drawn retain their alpha values. This enables multiple layers of OF apps or OF apps overlaying other apps
Example code:
#include "ofMain.h"
#include "ofAppEGLWindow.h"
class ofApp : public ofBaseApp{
public:
void draw()
{
//Set background to alpha 0
ofColor bgColor(ofColor::black, 0);
ofBackground(bgColor);
int alpha = ofGetFrameNum()%255;
ofPushStyle();
ofColor orangeBG(ofColor::orange, alpha);
ofSetColor(orangeBG);
ofDrawRectangle(0, 0, 500, 500);
ofPopStyle();
}
};
int main( )
{
ofGLESWindowSettings windowSettings;
windowSettings.setSize(1024, 768);
ofAppEGLWindow::Settings settings(windowSettings);
settings.eglWindowOpacity = 0;
settings.alphaFlags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE; //proposed change
settings.layer = 2;
ofCreateWindow(settings);
ofRunApp(new ofApp());
}
With the above code you could start another app (e.g. omxplayer, another OF app) and an orange box would be drawn on top with transparency retained.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ofAppEGLWindow.h and the Raspberry Pi window settings shown in the example, then trace how eglWindowOpacity is applied when the window is created. Expose the alpha flag options through the settings used by ofAppEGLWindow. Done means callers can select DISPMANX_FLAGS_ALPHA_FROM_SOURCE or another listed flag and preserve the intended per-element alpha behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, raspberry-pi
- Domain
- computer-graphics, embedded-iot
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100