Shadow map work & failing to fix audio engine bug

This commit is contained in:
austin 2021-11-07 11:56:13 -05:00
parent dc1c05546e
commit 419436f968
2 changed files with 20 additions and 15 deletions

View File

@ -10,8 +10,11 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.joml.Matrix4f;
import org.lwjgl.openal.*;
import static org.lwjgl.openal.ALC10.*;
import org.lwjgl.openal.AL;
import org.lwjgl.openal.ALC;
//import org.lwjgl.openal.*;
import org.lwjgl.openal.ALC10;
import org.lwjgl.openal.ALCCapabilities;
import static org.lwjgl.system.MemoryUtil.NULL;
public class AudioEngine {
@ -44,16 +47,16 @@ public class AudioEngine {
}
void initDevice() throws Exception{
this.device = alcOpenDevice((ByteBuffer) null);
this.device = ALC10.alcOpenDevice((ByteBuffer) null);
if (device == NULL) {
throw new IllegalStateException("Failed to open the default OpenAL device.");
}
ALCCapabilities deviceCaps = ALC.createCapabilities(device);
this.context = alcCreateContext(device, (IntBuffer) null);
this.context = ALC10.alcCreateContext(device, (IntBuffer) null);
if (context == NULL) {
throw new IllegalStateException("Failed to create OpenAL context.");
}
alcMakeContextCurrent(context);
ALC10.alcMakeContextCurrent(context);
AL.createCapabilities(deviceCaps);
}

View File

@ -346,16 +346,18 @@ public class RenderingEngine {
// glBindTexture(GL_TEXTURE_2D, woodTexture);
// renderScene(simpleDepthShader);
float eyeX = -10.0f;
float eyeY = 20.0f;
float eyeZ = -5.0f;
float nearPlane = 0.001f;
float farPlane = (float)Math.sqrt(eyeX * eyeX + eyeY * eyeY + eyeZ * eyeZ) + 20.0f;
float eyeX = -1.0f;
float eyeY = 10.0f;
float eyeZ = -5.5f;
float nearPlane = 0.01f;
float eyeDist = (float)Math.sqrt(eyeX * eyeX + eyeY * eyeY + eyeZ * eyeZ);
float farPlane = eyeDist + 10.0f;
float sidesMagnitude = (float)Math.sqrt(eyeDist);
//set matrices for light render
Matrix4f lightProjection = new Matrix4f().setOrtho(-10.0f, 10.0f, -10.0f, 10.0f, nearPlane, farPlane);//glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, near_plane, far_plane);
Matrix4f lightProjection = new Matrix4f().setOrtho(-sidesMagnitude, sidesMagnitude, -sidesMagnitude, sidesMagnitude, nearPlane, farPlane);//glm::ortho(-10.0f, 10.0f, -10.0f, 10.0f, near_plane, far_plane);
Matrix4f lightView = new Matrix4f().setLookAt(
new Vector3f(eyeX, eyeY, eyeZ).add(CameraEntityUtils.getCameraCenter(Globals.playerCamera)),
new Vector3f( 0.0f, 0.0f, 0.0f).add(CameraEntityUtils.getCameraCenter(Globals.playerCamera)),
new Vector3f(eyeX, eyeY, eyeZ),
new Vector3f( 0.0f, 0.0f, 0.0f),
new Vector3f( 0.0f, 1.0f, 0.0f)
);
Globals.lightDepthMatrix = new Matrix4f(lightProjection).mul(lightView);
@ -388,8 +390,8 @@ public class RenderingEngine {
currentActor.applyModelMatrix(modelTransformMatrix);
//draw
// if(!currentEntity.getDataKeys().contains(EntityDataStrings.TERRAIN_IS_TERRAIN) && !currentEntity.getDataKeys().contains(EntityDataStrings.DATA_STRING_CREATURE_IS_CREATURE)){
currentActor.drawForDepthBuffer();
System.out.println(currentActor.modelPath);
currentActor.drawForDepthBuffer();
// System.out.println(currentActor.modelPath);
// }
}
}