good non vulkan changes and some common ones

pull/12/head
hYdos 2020-03-02 20:26:30 +10:00
parent 89b4a0902f
commit a7e3541668
9 changed files with 44 additions and 47 deletions

View File

@ -13,6 +13,7 @@ import com.github.hydos.ginger.engine.common.api.game.*;
import com.github.hydos.ginger.engine.common.cameras.*;
import com.github.hydos.ginger.engine.common.elements.objects.*;
import com.github.hydos.ginger.engine.common.font.FontType;
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.obj.ModelLoader;
import com.github.hydos.ginger.engine.common.obj.shapes.StaticCube;
@ -151,7 +152,7 @@ public class Litecraft extends Game
private void setupWindow()
{
Window.create(1280, 720, "LiteCraft", 60); // create window
Window.create(1280, 720, "LiteCraft", 60, RenderAPI.OpenGL); // create window
KeyCallbackHandler.trackWindow(Window.getWindow()); // set up the gateways keybind key tracking
MouseCallbackHandler.trackWindow(Window.getWindow());
}

View File

@ -33,7 +33,6 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable
private boolean fullyGenerated = false;
public final int dimension;
private boolean dirty = true;
private World world;
/**
* A holder for the rendered blocks in this chunk. This array is *NOT* safe to use for getting BIs at a position!
* It can vary in size from 0 to 512 elements long and must only be read linearly.

View File

@ -197,7 +197,7 @@ public class World implements BlockAccess, WorldGenConstants
public void unloadAllChunks()
{
LongList chunkPositions = new LongArrayList();
List<CompletableFuture> futures = new ArrayList<>();
@SuppressWarnings("rawtypes") List<CompletableFuture> futures = new ArrayList<>();
if (this.chunks != null)
{
this.chunks.forEach((pos, chunk) ->

View File

@ -10,8 +10,6 @@ import com.github.halotroop.litecraft.world.gen.WorldGenConstants;
public class CavesModifier implements WorldModifier, WorldGenConstants
{
private OctaveSimplexNoise caveNoise;
private static final double THRESHOLD = 0.1;
@Override
public void initialize(long seed)
{

View File

@ -0,0 +1,4 @@
package com.github.hydos.ginger.engine.common.info;
public enum RenderAPI
{OpenGL, Vulkan}

View File

@ -7,6 +7,7 @@ import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.*;
import org.lwjgl.opengl.*;
import com.github.hydos.ginger.engine.common.info.RenderAPI;
import com.github.hydos.ginger.engine.opengl.api.GingerGL;
import com.github.hydos.ginger.engine.opengl.render.texture.Image;
@ -26,7 +27,8 @@ public class Window
public static boolean isFullscreen()
{ return fullscreen; }
public static RenderAPI renderAPI;
private static int width, height;
private static String title;
private static long window;
@ -50,18 +52,23 @@ public class Window
public static boolean closed()
{ return GLFW.glfwWindowShouldClose(getWindow()); }
public static void create()
public static void create(RenderAPI api)
{
if (!GLFW.glfwInit())
{
System.err.println("Error: Couldn't initialize GLFW");
System.exit(-1);
}
renderAPI = api;
if(renderAPI == RenderAPI.OpenGL)
{
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 4);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 6);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GL11.GL_TRUE);
}else if (renderAPI == RenderAPI.Vulkan)
GLFW.glfwWindowHint(GLFW.GLFW_VISIBLE, GLFW.GLFW_FALSE);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MAJOR, 4);
GLFW.glfwWindowHint(GLFW.GLFW_CONTEXT_VERSION_MINOR, 6);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_PROFILE, GLFW.GLFW_OPENGL_CORE_PROFILE);
GLFW.glfwWindowHint(GLFW.GLFW_OPENGL_FORWARD_COMPAT, GL11.GL_TRUE);
GLFW.glfwWindowHint(GLFW.GLFW_RESIZABLE, GLFW.GLFW_TRUE);
GLFWVidMode vidmode = GLFW.glfwGetVideoMode(GLFW.glfwGetPrimaryMonitor());
window = GLFW.glfwCreateWindow(actualWidth, actualHeight, title, (fullscreen) ? GLFW.glfwGetPrimaryMonitor() : 0, getWindow());
@ -82,7 +89,7 @@ public class Window
oldWindowHeight = getHeight();
}
public static void create(int width, int height, String title, int fpsCap)
public static void create(int width, int height, String title, int fpsCap, RenderAPI api)
{
Window.width = width / 2;
Window.height = height / 2;
@ -90,7 +97,7 @@ public class Window
Window.actualWidth = width;
Window.title = title;
Window.fpsCap = fpsCap;
Window.create();
Window.create(api);
Window.setIcon();
}

View File

@ -1,22 +1,18 @@
package com.github.hydos.ginger.engine.vulkan.utils;
import java.nio.Buffer;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.vma.VmaAllocationCreateInfo;
import org.lwjgl.util.vma.VmaAllocationInfo;
import org.lwjgl.util.vma.VmaAllocatorCreateInfo;
import org.lwjgl.util.vma.VmaVulkanFunctions;
import org.lwjgl.vulkan.*;
import static org.lwjgl.vulkan.EXTDebugReport.*;
import static org.lwjgl.vulkan.KHR8bitStorage.*;
import static org.lwjgl.vulkan.KHRGetMemoryRequirements2.*;
import static org.lwjgl.vulkan.EXTDebugReport.VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
import static org.lwjgl.vulkan.KHR8bitStorage.VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR;
import static org.lwjgl.vulkan.KHRGetMemoryRequirements2.VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR;
import static org.lwjgl.vulkan.KHRGetPhysicalDeviceProperties2.*;
import static org.lwjgl.vulkan.KHRShaderFloat16Int8.*;
import static org.lwjgl.vulkan.KHRShaderFloat16Int8.VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR;
import static org.lwjgl.vulkan.KHRSwapchain.*;
import static org.lwjgl.vulkan.NVRayTracing.*;
import static org.lwjgl.vulkan.VK10.*;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.vma.*;
import org.lwjgl.vulkan.*;
public class VKFactory {
static VmaVulkanFunctions VmaVulkanFunctions(MemoryStack stack) {
return VmaVulkanFunctions.callocStack(stack);

View File

@ -1,7 +1,5 @@
package com.github.hydos.ginger.engine.vulkan.utils;
import org.lwjgl.vulkan.VK12;
/**
*
* @author hydos

View File

@ -1,31 +1,25 @@
package com.github.hydos.ginger.engine.vulkan.utils;
import org.lwjgl.assimp.*;
import org.lwjgl.system.Callback;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.util.shaderc.ShadercIncludeResolve;
import org.lwjgl.util.shaderc.ShadercIncludeResult;
import org.lwjgl.util.shaderc.ShadercIncludeResultRelease;
import org.lwjgl.vulkan.*;
import com.github.hydos.ginger.engine.opengl.render.tools.IOUtil;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.util.ArrayList;
import java.util.List;
import static org.lwjgl.BufferUtils.*;
import static org.lwjgl.BufferUtils.createByteBuffer;
import static org.lwjgl.assimp.Assimp.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.util.shaderc.Shaderc.*;
import static org.lwjgl.vulkan.EXTDebugReport.*;
import static org.lwjgl.vulkan.KHRDisplaySwapchain.*;
import static org.lwjgl.vulkan.EXTDebugReport.VK_ERROR_VALIDATION_FAILED_EXT;
import static org.lwjgl.vulkan.KHRDisplaySwapchain.VK_ERROR_INCOMPATIBLE_DISPLAY_KHR;
import static org.lwjgl.vulkan.KHRSurface.*;
import static org.lwjgl.vulkan.KHRSwapchain.*;
import static org.lwjgl.vulkan.NVRayTracing.*;
import static org.lwjgl.vulkan.VK12.*;
import static org.lwjgl.vulkan.VK10.*;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.*;
import org.lwjgl.assimp.*;
import org.lwjgl.system.*;
import org.lwjgl.util.shaderc.*;
import com.github.hydos.ginger.engine.opengl.render.tools.IOUtil;
/**
* Utility functions for Vulkan.