add lwjgl debug stuff

liteCraft
hayden v 2020-03-05 10:39:48 +10:00
parent adfdfccd64
commit 14db9b4a22
2 changed files with 16 additions and 7 deletions

View File

@ -1,10 +1,11 @@
package com.github.hydos.ginger; package com.github.hydos.ginger;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.lwjgl.system.Configuration;
import com.github.hydos.ginger.engine.common.info.RenderAPI; import com.github.hydos.ginger.engine.common.info.RenderAPI;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
import com.github.hydos.ginger.engine.vulkan.api.*; import com.github.hydos.ginger.engine.vulkan.api.GingerVK;
/** @author hydos06 /** @author hydos06
* the non ARR vulkan test example */ * the non ARR vulkan test example */
@ -33,7 +34,7 @@ public class VulkanStarter
} }
private void mainLoop() { private void mainLoop() {
while(!Window.closed()) { while(!Window.closed()) {
if(Window.shouldRender()) { if(Window.shouldRender()) {
Window.update(); Window.update();
@ -52,7 +53,7 @@ public class VulkanStarter
} }
public static void main(String[] args) { public static void main(String[] args) {
Configuration.DEBUG.set(true);
BasicGinger2VulkanExample app = new BasicGinger2VulkanExample(); BasicGinger2VulkanExample app = new BasicGinger2VulkanExample();
app.run(); app.run();

View File

@ -4,6 +4,7 @@ import java.nio.*;
import java.util.*; import java.util.*;
import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil;
import org.lwjgl.vulkan.*; import org.lwjgl.vulkan.*;
import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.common.io.Window;
@ -109,7 +110,7 @@ public class Swapchain
imageCount.put(0, swapChainSupport.capabilities.maxImageCount()); imageCount.put(0, swapChainSupport.capabilities.maxImageCount());
} }
VkSwapchainCreateInfoKHR createInfo = VkSwapchainCreateInfoKHR.callocStack(stack) VkSwapchainCreateInfoKHR createInfo = VkSwapchainCreateInfoKHR.calloc()
.sType(KHRSwapchain.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR) .sType(KHRSwapchain.VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR)
.minImageCount(imageCount.get(0)) .minImageCount(imageCount.get(0))
.imageFormat(surfaceFormat.format()) .imageFormat(surfaceFormat.format())
@ -132,11 +133,18 @@ public class Swapchain
createInfo.presentMode(presentMode); createInfo.presentMode(presentMode);
createInfo.clipped(true); createInfo.clipped(true);
createInfo.oldSwapchain(VK12.VK_NULL_HANDLE); createInfo.oldSwapchain(1);
LongBuffer pSwapChain = stack.longs(VK12.VK_NULL_HANDLE); LongBuffer pSwapChain = MemoryUtil.memAllocLong(1);
int result = KHRSwapchain.vkCreateSwapchainKHR(VKConstants.device, createInfo, null, pSwapChain); int result = KHRSwapchain.
vkCreateSwapchainKHR
(
VKConstants.device,
createInfo,
null,
pSwapChain
);
if(result != VK12.VK_SUCCESS) { if(result != VK12.VK_SUCCESS) {
throw new RuntimeException("Failed to create swap chain reason: " + VKUtils.translateVulkanResult(result)); throw new RuntimeException("Failed to create swap chain reason: " + VKUtils.translateVulkanResult(result));
} }