diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index a6b7cdf..e379b65 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -4,7 +4,7 @@ "name": "Win32", "includePath": [ "${workspaceFolder}/**", - "C:/Program Files/Eclipse Adoptium/jdk-17.0.10.7-hotspot/include/**" + "C:/Program Files/Eclipse Adoptium/jdk-21.0.5.11-hotspot/include/**" ], "defines": [ "_DEBUG", @@ -12,7 +12,7 @@ "_UNICODE" ], "windowsSdkVersion": "10.0.19041.0", - "compilerPath": "C:/Program Files/w64devkit/bin/gcc.exe", + "compilerPath": "C:/ProgramData/mingw64/mingw64/bin/gcc.exe", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "windows-gcc-x64" diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..17e4f9f --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "ms-vscode.cpptools-extension-pack", + "vscjava.vscode-java-pack" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d68c91d --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# Fluid Sim + + + +## How to run + +Clone with `git clone --recurse-submodules git@git.austinwhoover.com:studiorailgun/fluid-sim.git` + +Then run with VSCode debug plugin + + diff --git a/src/main/java/electrosphere/FluidSim.java b/src/main/java/electrosphere/FluidSim.java index 168dde9..17b3ee7 100644 --- a/src/main/java/electrosphere/FluidSim.java +++ b/src/main/java/electrosphere/FluidSim.java @@ -9,15 +9,9 @@ import java.nio.FloatBuffer; import java.nio.file.Files; import java.util.LinkedList; import java.util.List; -import java.util.Random; -import java.util.Set; -import org.joml.Vector2i; import org.joml.Vector3i; -import org.lwjgl.BufferUtils; -import org.lwjgl.PointerBuffer; import org.lwjgl.glfw.GLFW; -import org.lwjgl.system.MemoryUtil; /** * Simulates a fluid via opencl @@ -115,7 +109,6 @@ public class FluidSim { FloatBuffer vf = vVector[13].asFloatBuffer(); FloatBuffer wf = wVector[13].asFloatBuffer(); - Random rand = new Random(1); //make a cube of water in the center for(int i = 0; i < DIM; i++){ for(int j = 0; j < DIM; j++){ diff --git a/src/main/java/electrosphere/Main.java b/src/main/java/electrosphere/Main.java index 9aff2e9..aa69788 100644 --- a/src/main/java/electrosphere/Main.java +++ b/src/main/java/electrosphere/Main.java @@ -2,13 +2,9 @@ package electrosphere; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.nio.ByteBuffer; -import java.nio.ByteOrder; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Scanner; import java.util.concurrent.TimeUnit; import org.joml.Vector3i; @@ -29,12 +25,11 @@ public class Main { public static void main(String args[]){ - int dim = 1; - int vdim = 1; + int dim = 3; + int vdim = 3; int i = 0; long time = 0; long lastTime = 0; - Scanner scan = new Scanner(System.in); try { diff --git a/src/main/java/electrosphere/render/GLFWContext.java b/src/main/java/electrosphere/render/GLFWContext.java index e28db56..84c2574 100644 --- a/src/main/java/electrosphere/render/GLFWContext.java +++ b/src/main/java/electrosphere/render/GLFWContext.java @@ -2,7 +2,6 @@ package electrosphere.render; import java.nio.IntBuffer; -import org.lwjgl.BufferUtils; import org.lwjgl.glfw.GLFW; import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL44; @@ -38,9 +37,6 @@ public class GLFWContext { GLFW.glfwMakeContextCurrent(window); //Maximize it GLFW.glfwMaximizeWindow(window); - //grab actual framebuffer - int bufferWidth = 0; - int bufferHeight = 0; try(MemoryStack stack = MemoryStack.stackPush()){ IntBuffer xBuffer = MemoryUtil.memAllocInt(1); @@ -48,9 +44,6 @@ public class GLFWContext { GLFW.glfwGetFramebufferSize(window, xBuffer, yBuffer); MemoryUtil.memFree(xBuffer); MemoryUtil.memFree(yBuffer); - - bufferWidth = xBuffer.get(); - bufferHeight = yBuffer.get(); } // diff --git a/src/main/java/electrosphere/render/Mesh.java b/src/main/java/electrosphere/render/Mesh.java index 288d32e..7bd8f77 100644 --- a/src/main/java/electrosphere/render/Mesh.java +++ b/src/main/java/electrosphere/render/Mesh.java @@ -1,11 +1,8 @@ package electrosphere.render; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.File; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.nio.FloatBuffer; import java.nio.IntBuffer; import java.nio.file.Files; @@ -17,11 +14,8 @@ import java.util.Map; import org.joml.Matrix4f; import org.joml.Vector3f; import org.joml.Vector3i; -import org.lwjgl.BufferUtils; -import org.lwjgl.opengl.GL33; import org.lwjgl.opengl.GL44; import org.lwjgl.opengl.GL45; -import org.lwjgl.system.MemoryStack; import org.lwjgl.system.MemoryUtil; import electrosphere.FluidSim; @@ -110,7 +104,6 @@ public class Mesh { FloatBuffer NormalArrayBufferData; if(normalCount > 0){ NormalArrayBufferData = MemoryUtil.memAllocFloat(normalCount * 3); - float[] temp = new float[3]; for(float normalValue : data.normals){ NormalArrayBufferData.put(normalValue); } @@ -242,8 +235,7 @@ public class Mesh { public static void initShaderProgram(){ String vsSrc = ""; - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - try (BufferedReader is = new BufferedReader(Files.newBufferedReader(new File("C:\\Users\\satellite\\Documents\\fluid-sim\\src\\main\\resources\\shader.vs").toPath()))){ + try (BufferedReader is = new BufferedReader(Files.newBufferedReader(new File("./src/main/resources/shader.vs").toPath()))){ String temp; while((temp = is.readLine())!=null){ vsSrc = vsSrc + temp + "\n"; @@ -254,7 +246,7 @@ public class Mesh { } String fsSrc = ""; - try (BufferedReader is = new BufferedReader(Files.newBufferedReader(new File("C:\\Users\\satellite\\Documents\\fluid-sim\\src\\main\\resources\\shader.fs").toPath()))){ + try (BufferedReader is = new BufferedReader(Files.newBufferedReader(new File("./src/main/resources/shader.fs").toPath()))){ String temp; while((temp = is.readLine())!=null){ fsSrc = fsSrc + temp + "\n";