private void wglNvSwapGroupAndBarrier(GLData attribs, long bufferAddr, long hDC) throws AWTException { int success; long wglQueryMaxSwapGroupsNVAddr = WGL.wglGetProcAddress("wglQueryMaxSwapGroupsNV"); success = JNI.callPPPI(wglQueryMaxSwapGroupsNVAddr, hDC, bufferAddr, bufferAddr + 4); int maxGroups = MemoryUtil.memGetInt(bufferAddr); if (maxGroups < attribs.swapGroupNV) { throw new AWTException("Swap group exceeds maximum group index"); } int maxBarriers = MemoryUtil.memGetInt(bufferAddr + 4); if (maxBarriers < attribs.swapBarrierNV) { throw new AWTException("Swap barrier exceeds maximum barrier index"); } if (attribs.swapGroupNV > 0) { long wglJoinSwapGroupNVAddr = WGL.wglGetProcAddress("wglJoinSwapGroupNV"); if (wglJoinSwapGroupNVAddr == 0L) { throw new AWTException("WGL_NV_swap_group available but wglJoinSwapGroupNV is NULL"); } success = JNI.callPI(wglJoinSwapGroupNVAddr, hDC, attribs.swapGroupNV); if (success == 0) { throw new AWTException("Failed to join swap group"); } if (attribs.swapBarrierNV > 0) { long wglBindSwapBarrierNVAddr = WGL.wglGetProcAddress("wglBindSwapBarrierNV"); if (wglBindSwapBarrierNVAddr == 0L) { throw new AWTException("WGL_NV_swap_group available but wglBindSwapBarrierNV is NULL"); } success = JNI.callI(wglBindSwapBarrierNVAddr, attribs.swapGroupNV, attribs.swapBarrierNV); if (success == 0) { throw new AWTException("Failed to bind swap barrier. Probably no G-Sync card installed."); } } } }
public boolean delayBeforeSwapNV(float seconds) { if (!wglDelayBeforeSwapNVAddr_set) { wglDelayBeforeSwapNVAddr = WGL.wglGetProcAddress("wglDelayBeforeSwapNV"); wglDelayBeforeSwapNVAddr_set = true; } if (wglDelayBeforeSwapNVAddr == 0L) { throw new UnsupportedOperationException("wglDelayBeforeSwapNV is unavailable"); } long hDC = User32.GetDC(hwnd); int ret = JNI.callPI(wglDelayBeforeSwapNVAddr, hDC, seconds); User32.ReleaseDC(hwnd, hDC); return ret == 1; }
private void wglNvSwapGroupAndBarrier(GLData attribs, long bufferAddr, long hDC) throws SWTException { int success; long wglQueryMaxSwapGroupsNVAddr = WGL.wglGetProcAddress("wglQueryMaxSwapGroupsNV"); success = JNI.callPPPI(wglQueryMaxSwapGroupsNVAddr, hDC, bufferAddr, bufferAddr + 4); int maxGroups = MemoryUtil.memGetInt(bufferAddr); if (maxGroups < attribs.swapGroupNV) { throw new SWTException("Swap group exceeds maximum group index"); } int maxBarriers = MemoryUtil.memGetInt(bufferAddr + 4); if (maxBarriers < attribs.swapBarrierNV) { throw new SWTException("Swap barrier exceeds maximum barrier index"); } if (attribs.swapGroupNV > 0) { long wglJoinSwapGroupNVAddr = WGL.wglGetProcAddress("wglJoinSwapGroupNV"); if (wglJoinSwapGroupNVAddr == 0L) { throw new SWTException("WGL_NV_swap_group available but wglJoinSwapGroupNV is NULL"); } success = JNI.callPI(wglJoinSwapGroupNVAddr, hDC, attribs.swapGroupNV); if (success == 0) { throw new SWTException("Failed to join swap group"); } if (attribs.swapBarrierNV > 0) { long wglBindSwapBarrierNVAddr = WGL.wglGetProcAddress("wglBindSwapBarrierNV"); if (wglBindSwapBarrierNVAddr == 0L) { throw new SWTException("WGL_NV_swap_group available but wglBindSwapBarrierNV is NULL"); } success = JNI.callI(wglBindSwapBarrierNVAddr, attribs.swapGroupNV, attribs.swapBarrierNV); if (success == 0) { throw new SWTException("Failed to bind swap barrier. Probably no G-Sync card installed."); } } } }
public boolean delayBeforeSwapNV(GLCanvas canvas, float seconds) { if (!wglDelayBeforeSwapNVAddr_set) { wglDelayBeforeSwapNVAddr = WGL.wglGetProcAddress("wglDelayBeforeSwapNV"); wglDelayBeforeSwapNVAddr_set = true; } if (wglDelayBeforeSwapNVAddr == 0L) { throw new UnsupportedOperationException("wglDelayBeforeSwapNV is unavailable"); } long hDC = User32.GetDC(canvas.handle); int ret = JNI.callPI(wglDelayBeforeSwapNVAddr, hDC, seconds); User32.ReleaseDC(canvas.handle, hDC); return ret == 1; }
@Override public void init() { super.init(); WindowManager.createWindow(handle, window, true); ResourceLoader loader = window.getResourceLoader(); segoeui = loader.loadNVGFont("C:\\Windows\\Fonts\\segoeui", "Segoe UI", true); segoemdl2 = loader.loadNVGFont("C:\\Windows\\Fonts\\segmdl2", "Segoe MDL2", true); compWin = new ComponentWindow(window); compWin.init(window); compWin.setBackgroundColor(0, 0, 0, 0); compWin.setLayout(new FlowLayout(Direction.UP, 0, 0)); compWin.getTitlebar().setEnabled(false); long hwndGLFW = glfwGetWin32Window(window.getID()); local = new HWND(Pointer.createConstant(hwndGLFW)); AccentPolicy accent = new AccentPolicy(); accent.AccentState = Accent.ACCENT_ENABLE_ACRYLIC; accent.GradientColor = 0x7F000000; accent.AccentFlags = 2; int accentStructSize = accent.size(); accent.write(); Pointer accentPtr = accent.getPointer(); WindowCompositionAttributeData data = new WindowCompositionAttributeData(); data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY; data.SizeOfData = accentStructSize; data.Data = accentPtr; User32Ext.INSTANCE.SetWindowCompositionAttribute(local, data); long dwp = User32Ext.INSTANCE.GetWindowLongPtr(local, GWL_WNDPROC); WindowProc proc = new WindowProc() { @Override public long invoke(long hw, int uMsg, long wParam, long lParam) { if (hw == hwndGLFW) switch (uMsg) { case WM_KILLFOCUS: TaskManager.addTask(() -> window.setVisible(false)); break; } return JNI.callPPPP(dwp, hw, uMsg, wParam, lParam); } }; User32.INSTANCE.SetWindowLongPtr(local, GWL_WNDPROC, Pointer.createConstant(proc.address())); User32Ext.INSTANCE.SetWindowLongPtr(local, GWL_EXSTYLE, WS_EX_TOOLWINDOW); }
@Override public void init() { super.init(); WindowManager.createWindow(handle, window, true); ResourceLoader loader = window.getResourceLoader(); segoeui = loader.loadNVGFont("C:\\Windows\\Fonts\\segoeui", "Segoe UI", true); segoemdl2 = loader.loadNVGFont("C:\\Windows\\Fonts\\segmdl2", "Segoe MDL2", true); compWin = new ComponentWindow(window); compWin.setBackgroundColor(0, 0, 0, 0); compWin.getTitlebar().setEnabled(false); long hwndGLFW = glfwGetWin32Window(window.getID()); local = new HWND(Pointer.createConstant(hwndGLFW)); AccentPolicy accent = new AccentPolicy(); accent.AccentState = Accent.ACCENT_ENABLE_ACRYLIC; accent.GradientColor = 0x7F000000; accent.AccentFlags = 2; int accentStructSize = accent.size(); accent.write(); Pointer accentPtr = accent.getPointer(); WindowCompositionAttributeData data = new WindowCompositionAttributeData(); data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY; data.SizeOfData = accentStructSize; data.Data = accentPtr; User32Ext.INSTANCE.SetWindowCompositionAttribute(local, data); long dwp = User32Ext.INSTANCE.GetWindowLongPtr(local, GWL_WNDPROC); WindowProc proc = new WindowProc() { @Override public long invoke(long hw, int uMsg, long wParam, long lParam) { if (hw == hwndGLFW) switch (uMsg) { case WM_KILLFOCUS: //DWMapiExt.INSTANCE.InvokeAeroPeek(false, hwndWin, local, 3, new INT_PTR(32), 0x3244); //DWMapiExt.INSTANCE.DwmpActivateLivePreview(0, hwndWin, local, 1); TaskManager.addTask(() -> window.setVisible(false)); break; } return JNI.callPPPP(dwp, hw, uMsg, wParam, lParam); } }; User32.INSTANCE.SetWindowLongPtr(local, GWL_WNDPROC, Pointer.createConstant(proc.address())); User32Ext.INSTANCE.SetWindowLongPtr(local, GWL_EXSTYLE, WS_EX_TOOLWINDOW); thumbnail = new IntByReference(); }
@Override public void init() { super.init(); WindowManager.createWindow(handle, window, true); ResourceLoader loader = window.getResourceLoader(); segoeui = loader.loadNVGFont("C:\\Windows\\Fonts\\segoeui", "Segoe UI", true); segoemdl2 = loader.loadNVGFont("C:\\Windows\\Fonts\\segmdl2", "Segoe MDL2", true); compWin = new ComponentWindow(window); compWin.init(window); compWin.setBackgroundColor(0, 0, 0, 0); compWin.getTitlebar().setEnabled(false); icons = new Container(0, 0, 200, 200); icons.setLayout(new FlowLayout(Direction.RIGHT, 0, 0)); compWin.addComponent(icons); long hwndGLFW = glfwGetWin32Window(window.getID()); local = new HWND(Pointer.createConstant(hwndGLFW)); AccentPolicy accent = new AccentPolicy(); accent.AccentState = Accent.ACCENT_ENABLE_BLURBEHIND; accent.GradientColor = 0xBE282828; accent.AccentFlags = 2; int accentStructSize = accent.size(); accent.write(); Pointer accentPtr = accent.getPointer(); WindowCompositionAttributeData data = new WindowCompositionAttributeData(); data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY; data.SizeOfData = accentStructSize; data.Data = accentPtr; User32Ext.INSTANCE.SetWindowCompositionAttribute(local, data); long dwp = User32Ext.INSTANCE.GetWindowLongPtr(local, GWL_WNDPROC); WindowProc proc = new WindowProc() { @Override public long invoke(long hw, int uMsg, long wParam, long lParam) { if (hw == hwndGLFW) switch (uMsg) { case WM_KILLFOCUS: TaskManager.addTask(() -> window.setVisible(false)); break; } return JNI.callPPPP(dwp, hw, uMsg, wParam, lParam); } }; User32.INSTANCE.SetWindowLongPtr(local, GWL_WNDPROC, Pointer.createConstant(proc.address())); User32Ext.INSTANCE.SetWindowLongPtr(local, GWL_EXSTYLE, WS_EX_TOOLWINDOW); }