Skip to content

Commit

Permalink
Improve error handling of the translucent window sample
Browse files Browse the repository at this point in the history
  • Loading branch information
knokko committed Mar 18, 2024
1 parent dcb9f68 commit 9081f2c
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.knokko.boiler.builder.BoilerBuilder;
import com.github.knokko.boiler.builder.BoilerSwapchainBuilder;
import com.github.knokko.boiler.builder.device.SimpleDeviceSelector;
import com.github.knokko.boiler.builder.instance.ValidationFeatures;
import com.github.knokko.boiler.builder.swapchain.SimpleCompositeAlphaPicker;
import com.github.knokko.boiler.commands.CommandRecorder;
Expand All @@ -18,13 +19,19 @@
import static java.lang.Thread.sleep;
import static org.lwjgl.glfw.GLFW.*;
import static org.lwjgl.system.MemoryStack.stackPush;
import static org.lwjgl.system.MemoryUtil.memUTF8;
import static org.lwjgl.vulkan.KHRSurface.*;
import static org.lwjgl.vulkan.KHRSwapchain.VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
import static org.lwjgl.vulkan.VK10.*;

public class TranslucentWindowPlayground {

public static void main(String[] args) throws InterruptedException {
//noinspection resource
glfwSetErrorCallback(
(error, description) -> System.out.println("[GLFW]: " + memUTF8(description) + " (" + error + ")")
);

// Wayland's windows have cool transparency support
if (glfwPlatformSupported(GLFW_PLATFORM_WAYLAND)) glfwInitHint(GLFW_PLATFORM, GLFW_PLATFORM_WAYLAND);
if (!glfwInit()) {
Expand Down Expand Up @@ -53,6 +60,8 @@ public static void main(String[] args) throws InterruptedException {
VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR,
VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR
)))
// Avoid annoying crashes on laptops with multiple GPUs by preferring the integrated GPU
.physicalDeviceSelector(new SimpleDeviceSelector(VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU))
.build();

System.out.printf(
Expand Down

0 comments on commit 9081f2c

Please sign in to comment.