updates
All checks were successful
studiorailgun/fluid-sim/pipeline/head This commit looks good

This commit is contained in:
austin 2024-11-30 13:26:55 -05:00
parent db89bc4ff4
commit 7cb7ef646c
7 changed files with 23 additions and 33 deletions

View File

@ -4,7 +4,7 @@
"name": "Win32", "name": "Win32",
"includePath": [ "includePath": [
"${workspaceFolder}/**", "${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": [ "defines": [
"_DEBUG", "_DEBUG",
@ -12,7 +12,7 @@
"_UNICODE" "_UNICODE"
], ],
"windowsSdkVersion": "10.0.19041.0", "windowsSdkVersion": "10.0.19041.0",
"compilerPath": "C:/Program Files/w64devkit/bin/gcc.exe", "compilerPath": "C:/ProgramData/mingw64/mingw64/bin/gcc.exe",
"cStandard": "c17", "cStandard": "c17",
"cppStandard": "c++17", "cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64" "intelliSenseMode": "windows-gcc-x64"

6
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"recommendations": [
"ms-vscode.cpptools-extension-pack",
"vscjava.vscode-java-pack"
]
}

11
README.md Normal file
View File

@ -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

View File

@ -9,15 +9,9 @@ import java.nio.FloatBuffer;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Random;
import java.util.Set;
import org.joml.Vector2i;
import org.joml.Vector3i; import org.joml.Vector3i;
import org.lwjgl.BufferUtils;
import org.lwjgl.PointerBuffer;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.lwjgl.system.MemoryUtil;
/** /**
* Simulates a fluid via opencl * Simulates a fluid via opencl
@ -115,7 +109,6 @@ public class FluidSim {
FloatBuffer vf = vVector[13].asFloatBuffer(); FloatBuffer vf = vVector[13].asFloatBuffer();
FloatBuffer wf = wVector[13].asFloatBuffer(); FloatBuffer wf = wVector[13].asFloatBuffer();
Random rand = new Random(1);
//make a cube of water in the center //make a cube of water in the center
for(int i = 0; i < DIM; i++){ for(int i = 0; i < DIM; i++){
for(int j = 0; j < DIM; j++){ for(int j = 0; j < DIM; j++){

View File

@ -2,13 +2,9 @@ package electrosphere;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.joml.Vector3i; import org.joml.Vector3i;
@ -29,12 +25,11 @@ public class Main {
public static void main(String args[]){ public static void main(String args[]){
int dim = 1; int dim = 3;
int vdim = 1; int vdim = 3;
int i = 0; int i = 0;
long time = 0; long time = 0;
long lastTime = 0; long lastTime = 0;
Scanner scan = new Scanner(System.in);
try { try {

View File

@ -2,7 +2,6 @@ package electrosphere.render;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import org.lwjgl.opengl.GL; import org.lwjgl.opengl.GL;
import org.lwjgl.opengl.GL44; import org.lwjgl.opengl.GL44;
@ -38,9 +37,6 @@ public class GLFWContext {
GLFW.glfwMakeContextCurrent(window); GLFW.glfwMakeContextCurrent(window);
//Maximize it //Maximize it
GLFW.glfwMaximizeWindow(window); GLFW.glfwMaximizeWindow(window);
//grab actual framebuffer
int bufferWidth = 0;
int bufferHeight = 0;
try(MemoryStack stack = MemoryStack.stackPush()){ try(MemoryStack stack = MemoryStack.stackPush()){
IntBuffer xBuffer = MemoryUtil.memAllocInt(1); IntBuffer xBuffer = MemoryUtil.memAllocInt(1);
@ -48,9 +44,6 @@ public class GLFWContext {
GLFW.glfwGetFramebufferSize(window, xBuffer, yBuffer); GLFW.glfwGetFramebufferSize(window, xBuffer, yBuffer);
MemoryUtil.memFree(xBuffer); MemoryUtil.memFree(xBuffer);
MemoryUtil.memFree(yBuffer); MemoryUtil.memFree(yBuffer);
bufferWidth = xBuffer.get();
bufferHeight = yBuffer.get();
} }
// //

View File

@ -1,11 +1,8 @@
package electrosphere.render; package electrosphere.render;
import java.io.BufferedInputStream;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.nio.file.Files; import java.nio.file.Files;
@ -17,11 +14,8 @@ import java.util.Map;
import org.joml.Matrix4f; import org.joml.Matrix4f;
import org.joml.Vector3f; import org.joml.Vector3f;
import org.joml.Vector3i; import org.joml.Vector3i;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.GL33;
import org.lwjgl.opengl.GL44; import org.lwjgl.opengl.GL44;
import org.lwjgl.opengl.GL45; import org.lwjgl.opengl.GL45;
import org.lwjgl.system.MemoryStack;
import org.lwjgl.system.MemoryUtil; import org.lwjgl.system.MemoryUtil;
import electrosphere.FluidSim; import electrosphere.FluidSim;
@ -110,7 +104,6 @@ public class Mesh {
FloatBuffer NormalArrayBufferData; FloatBuffer NormalArrayBufferData;
if(normalCount > 0){ if(normalCount > 0){
NormalArrayBufferData = MemoryUtil.memAllocFloat(normalCount * 3); NormalArrayBufferData = MemoryUtil.memAllocFloat(normalCount * 3);
float[] temp = new float[3];
for(float normalValue : data.normals){ for(float normalValue : data.normals){
NormalArrayBufferData.put(normalValue); NormalArrayBufferData.put(normalValue);
} }
@ -242,8 +235,7 @@ public class Mesh {
public static void initShaderProgram(){ public static void initShaderProgram(){
String vsSrc = ""; String vsSrc = "";
ClassLoader classloader = Thread.currentThread().getContextClassLoader(); try (BufferedReader is = new BufferedReader(Files.newBufferedReader(new File("./src/main/resources/shader.vs").toPath()))){
try (BufferedReader is = new BufferedReader(Files.newBufferedReader(new File("C:\\Users\\satellite\\Documents\\fluid-sim\\src\\main\\resources\\shader.vs").toPath()))){
String temp; String temp;
while((temp = is.readLine())!=null){ while((temp = is.readLine())!=null){
vsSrc = vsSrc + temp + "\n"; vsSrc = vsSrc + temp + "\n";
@ -254,7 +246,7 @@ public class Mesh {
} }
String fsSrc = ""; 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; String temp;
while((temp = is.readLine())!=null){ while((temp = is.readLine())!=null){
fsSrc = fsSrc + temp + "\n"; fsSrc = fsSrc + temp + "\n";