aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-10-19 07:46:31 +0200
committerSven Gothel <[email protected]>2012-10-19 07:46:31 +0200
commit416c7fc1b90cd7b34c251268bb83ebeea61d17d6 (patch)
tree331fb09271fc49c0f876879f3d3577e27a7319ed /src
parent1aea29bb5d253600213024fd2c12a91bf3599202 (diff)
NEWT / BCM-VC-IV: Fix transparency according to given capabilities
Tested manual w/ TestGearsES2NEWT on Raspberry Pi
Diffstat (limited to 'src')
-rw-r--r--src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java17
-rw-r--r--src/newt/native/bcm_vc_iv.c21
-rw-r--r--src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java8
3 files changed, 34 insertions, 12 deletions
diff --git a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
index 7b8d2e958..21fbea9ac 100644
--- a/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
+++ b/src/newt/classes/jogamp/newt/driver/bcm/vc/iv/WindowDriver.java
@@ -53,20 +53,19 @@ public class WindowDriver extends WindowImpl {
if(0!=getParentWindowHandle()) {
throw new RuntimeException("Window parenting not supported (yet)");
}
- // FIXME: Hack - Native BCM_VC_IV code CreateWindow() uses the default alpha value setting,
- // which is alpha:8 ! Hence we require to chose alpha from the egl configurations.
- // TODO: Properly select the alpha mode in CreateWindow()! This will allow this hack.
- final Capabilities capsChosen = (Capabilities) capsRequested.cloneMutable();
- capsChosen.setAlphaBits(1);
final AbstractGraphicsConfiguration cfg = GraphicsConfigurationFactory.getFactory(getScreen().getDisplay().getGraphicsDevice(), capsRequested).chooseGraphicsConfiguration(
- capsChosen, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED);
+ capsRequested, capsRequested, capabilitiesChooser, getScreen().getGraphicsScreen(), VisualIDHolder.VID_UNDEFINED);
if (null == cfg) {
throw new NativeWindowException("Error choosing GraphicsConfiguration creating window: "+this);
}
+ final Capabilities chosenCaps = (Capabilities) cfg.getChosenCapabilities();
+ // FIXME: Pass along opaque flag, since EGL doesn't determine it
+ if(capsRequested.isBackgroundOpaque() != chosenCaps.isBackgroundOpaque()) {
+ chosenCaps.setBackgroundOpaque(capsRequested.isBackgroundOpaque());
+ }
setGraphicsConfiguration(cfg);
-
- nativeWindowHandle = CreateWindow(getWidth(), getHeight());
+ nativeWindowHandle = CreateWindow(getWidth(), getHeight(), chosenCaps.isBackgroundOpaque(), chosenCaps.getAlphaBits());
if (nativeWindowHandle == 0) {
throw new NativeWindowException("Error creating egl window: "+cfg);
}
@@ -139,7 +138,7 @@ public class WindowDriver extends WindowImpl {
//
protected static native boolean initIDs();
- private native long CreateWindow(int width, int height);
+ private native long CreateWindow(int width, int height, boolean opaque, int alphaBits);
private native long RealizeWindow(long eglWindowHandle);
private native int CloseWindow(long eglWindowHandle, long userData);
private native void setVisible0(long eglWindowHandle, boolean visible);
diff --git a/src/newt/native/bcm_vc_iv.c b/src/newt/native/bcm_vc_iv.c
index e41745e14..0093da437 100644
--- a/src/newt/native/bcm_vc_iv.c
+++ b/src/newt/native/bcm_vc_iv.c
@@ -101,8 +101,9 @@ JNIEXPORT void JNICALL Java_jogamp_newt_driver_bcm_vc_iv_ScreenDriver_initNative
if( graphics_get_display_size(0 /* LCD */, &screen_width, &screen_height) >= 0 ) {
DBG_PRINT( "BCM.Screen initNative ok %dx%d\n", screen_width, screen_height );
(*env)->CallVoidMethod(env, obj, setScreenSizeID, (jint) screen_width, (jint) screen_height);
+ } else {
+ DBG_PRINT( "BCM.Screen initNative failed\n" );
}
- DBG_PRINT( "BCM.Screen initNative failed\n" );
}
/**
@@ -132,7 +133,7 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_initID
}
JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWindow
- (JNIEnv *env, jobject obj, jint width, jint height)
+ (JNIEnv *env, jobject obj, jint width, jint height, jboolean opaque, jint alphaBits)
{
int32_t success = 0;
VC_RECT_T dst_rect;
@@ -148,12 +149,26 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_bcm_vc_iv_WindowDriver_CreateWin
src_rect.width = width << 16;
src_rect.height = height << 16;
+ VC_DISPMANX_ALPHA_T dispman_alpha;
+ memset(&dispman_alpha, 0x0, sizeof(VC_DISPMANX_ALPHA_T));
+
+ if( JNI_TRUE == opaque ) {
+ dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS ;
+ dispman_alpha.opacity = 0xFF;
+ dispman_alpha.mask = 0;
+ } else {
+ dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FROM_SOURCE ;
+ dispman_alpha.opacity = 0xFF;
+ dispman_alpha.mask = 0xFF;
+ }
+
DISPMANX_DISPLAY_HANDLE_T dispman_display = vc_dispmanx_display_open( 0 /* LCD */);
DISPMANX_UPDATE_HANDLE_T dispman_update = vc_dispmanx_update_start( 0 );
DISPMANX_ELEMENT_HANDLE_T dispman_element = vc_dispmanx_element_add ( dispman_update, dispman_display,
0/*layer*/, &dst_rect, 0/*src*/,
&src_rect, DISPMANX_PROTECTION_NONE,
- 0 /*alpha TODO*/, 0/*clamp*/, 0/*transform*/);
+ &dispman_alpha /*alpha */, 0/*clamp*/, 0/*transform*/);
+
EGL_DISPMANX_WINDOW_T * nativeWindowPtr = calloc(1, sizeof(EGL_DISPMANX_WINDOW_T));
nativeWindowPtr->element = dispman_element;
nativeWindowPtr->width = width;
diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
index a79c924d6..1620985c1 100644
--- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
+++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/newt/TestGearsES2NEWT.java
@@ -75,6 +75,7 @@ public class TestGearsES2NEWT extends UITestCase {
static long duration = 500; // ms
static boolean opaque = true;
+ static int forceAlpha = -1;
static boolean undecorated = false;
static boolean alwaysOnTop = false;
static boolean fullscreen = false;
@@ -257,6 +258,9 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("Loop "+i+"/"+loops);
GLCapabilities caps = new GLCapabilities(forceES2 ? GLProfile.get(GLProfile.GLES2) : GLProfile.getGL2ES2());
caps.setBackgroundOpaque(opaque);
+ if(-1 < forceAlpha) {
+ caps.setAlphaBits(forceAlpha);
+ }
runTestGL(caps, undecorated);
if(loop_shutdown) {
GLProfile.shutdown();
@@ -274,6 +278,9 @@ public class TestGearsES2NEWT extends UITestCase {
duration = MiscUtils.atol(args[i], duration);
} else if(args[i].equals("-translucent")) {
opaque = false;
+ } else if(args[i].equals("-forceAlpha")) {
+ i++;
+ forceAlpha = MiscUtils.atoi(args[i], 0);
} else if(args[i].equals("-undecorated")) {
undecorated = true;
} else if(args[i].equals("-atop")) {
@@ -328,6 +335,7 @@ public class TestGearsES2NEWT extends UITestCase {
System.err.println("size "+wsize);
System.err.println("screen "+screenIdx);
System.err.println("translucent "+(!opaque));
+ System.err.println("forceAlpha "+forceAlpha);
System.err.println("undecorated "+undecorated);
System.err.println("atop "+alwaysOnTop);
System.err.println("fullscreen "+fullscreen);