aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/windows
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-09-04 10:51:16 +0200
committerSven Gothel <[email protected]>2011-09-04 10:51:16 +0200
commitc8e147620c55ff16e9d687bb36a4374e97e82176 (patch)
tree3151189f2750801baf6ae1918adc3ff17b9c6833 /src/jogl/classes/jogamp/opengl/windows
parent3ea949b6a14c1ba631cb41b7439af86b21db4c05 (diff)
Complete translucency support for Win32 - tested w/ NEWT
https://jogamp.org/bugzilla/show_bug.cgi?id=517 - Adding some Windows DWM entries to GDI (manual) for translucency support - Add translucency setting in WindowsWGLGraphicsConfiguration*
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows')
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java22
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java8
2 files changed, 29 insertions, 1 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
index a82a7a38c..989906514 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfiguration.java
@@ -48,7 +48,9 @@ import javax.media.opengl.GLException;
import javax.media.opengl.GLPbuffer;
import javax.media.opengl.GLProfile;
+import jogamp.nativewindow.windows.DWM_BLURBEHIND;
import jogamp.nativewindow.windows.GDI;
+import jogamp.nativewindow.windows.MARGINS;
import jogamp.nativewindow.windows.PIXELFORMATDESCRIPTOR;
import jogamp.opengl.GLGraphicsConfigurationUtil;
@@ -164,9 +166,27 @@ public class WindowsWGLGraphicsConfiguration extends DefaultGraphicsConfiguratio
" for device context " + toHexString(hdc) +
": error code " + GDI.GetLastError());
}
+ if(!caps.isBackgroundOpaque()) {
+ final long hwnd = GDI.WindowFromDC(hdc);
+ DWM_BLURBEHIND bb = DWM_BLURBEHIND.create();
+ bb.setDwFlags(GDI.DWM_BB_ENABLE);
+ bb.setFEnable(1);
+ boolean ok = GDI.DwmEnableBlurBehindWindow(hwnd, bb);
+ if(ok) {
+ MARGINS m = MARGINS.create();
+ m.setCxLeftWidth(-1);
+ m.setCxRightWidth(-1);
+ m.setCyBottomHeight(-1);
+ m.setCyTopHeight(-1);
+ ok = GDI.DwmExtendFrameIntoClientArea(hwnd, m);
+ }
+ if(DEBUG) {
+ System.err.println("!!! translucency enabled on wnd: 0x"+Long.toHexString(hwnd)+" - ok: "+ok);
+ }
+ }
if (DEBUG) {
System.err.println("!!! setPixelFormat (ARB): hdc "+toHexString(hdc) +", "+caps);
- }
+ }
setCapsPFD(caps);
}
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
index 1c607d2c7..178f2777c 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLGraphicsConfigurationFactory.java
@@ -42,6 +42,7 @@ import javax.media.nativewindow.GraphicsConfigurationFactory;
import javax.media.nativewindow.CapabilitiesImmutable;
import javax.media.nativewindow.NativeSurface;
import javax.media.nativewindow.NativeWindowFactory;
+import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLCapabilitiesImmutable;
import javax.media.opengl.GLCapabilitiesChooser;
import javax.media.opengl.GLContext;
@@ -298,9 +299,14 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
GLCapabilitiesImmutable capsChosen = (GLCapabilitiesImmutable) config.getChosenCapabilities();
+ boolean isOpaque = capsChosen.isBackgroundOpaque() && GDI.DwmIsCompositionEnabled();
boolean onscreen = capsChosen.isOnscreen();
boolean usePBuffer = capsChosen.isPBuffer();
GLProfile glProfile = capsChosen.getGLProfile();
+
+ if(DEBUG) {
+ System.err.println("!!! translucency requested: "+(!capsChosen.isBackgroundOpaque())+", compositioning enabled: "+GDI.DwmIsCompositionEnabled()+" -> translucency "+(!isOpaque));
+ }
WGLGLCapabilities pixelFormatCaps = null; // chosen or preset PFD ID's caps
boolean pixelFormatSet = false; // indicates a preset PFD ID [caps]
@@ -316,6 +322,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
}
pixelFormatSet = true;
pixelFormatCaps = WindowsWGLGraphicsConfiguration.wglARBPFID2GLCapabilities(sharedResource, hdc, presetPFDID, glProfile, onscreen, usePBuffer);
+ pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque);
} else {
int recommendedIndex = -1; // recommended index
@@ -393,6 +400,7 @@ public class WindowsWGLGraphicsConfigurationFactory extends GLGraphicsConfigurat
" chosen pfdID: native recommended "+ (recommendedIndex+1) +
" chosen idx "+chosenIndex);
}
+ pixelFormatCaps = (WGLGLCapabilities) GLGraphicsConfigurationUtil.fixOpaqueGLCapabilities(pixelFormatCaps, isOpaque);
if (DEBUG) {
System.err.println("!!! chosen pfdID (ARB): native recommended "+ (recommendedIndex+1) +
" chosen "+pixelFormatCaps);