Skip to content

Commit

Permalink
Fixed opengl mistake, NPE Protection
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann Bernhardt committed Mar 10, 2021
1 parent 1e42f0b commit e7e6b53
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ public class HELightManager {

public static void onChunkUnload(int chunkX, int chunkZ) {
long key = HEUtil.chunkCoordsToKey(chunkX, chunkZ);
HELightChunk lightChunk = chunks.get(key);
lightChunk.reset();
availableBuffers.push(lightChunk);
chunks.remove(key);
if(chunks.containsKey(key)) {
HELightChunk lightChunk = chunks.get(key);
lightChunk.reset();
availableBuffers.push(lightChunk);
chunks.remove(key);
}
}

public static void onChunkDataLoad(Chunk chunk, int subChunkHasDataFlags) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ public class HEProgram {


public static void init() {
final int vertexShader = loadShader(vertexShaderLocation, GL20.GL_VERTEX_SHADER, "");
final int geometryShader = loadShader(geometryShaderLocation, GL32.GL_GEOMETRY_SHADER, "#define NUM_CONTROLLERS " + HE.maxController + "\n");
final int fragmentShader = loadShader(fragmentShaderLocation, GL20.GL_FRAGMENT_SHADER, "");
final String defines = "#version 330 core\n"
+ "#define NUM_CONTROLLERS " + HE.maxController + "\n";
final int vertexShader = loadShader(vertexShaderLocation, GL20.GL_VERTEX_SHADER, defines);
final int geometryShader = loadShader(geometryShaderLocation, GL32.GL_GEOMETRY_SHADER, defines);
final int fragmentShader = loadShader(fragmentShaderLocation, GL20.GL_FRAGMENT_SHADER, defines);

programID = GL20.glCreateProgram();
GL20.glAttachShader(programID, vertexShader);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/sinthoras/hydroenergy/server/HEDam.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ public void placeController(int blockX, int blockY, int blockZ) {
removeWater = false;
isPlaced = true;
isDebugMode = true;
limitEast = blockX + 100;
limitWest = blockX - 100;
limitUp = blockY+16;
limitEast = blockX + 200;
limitWest = blockX - 200;
limitUp = blockY+32;
limitDown = blockY;
limitSouth = blockZ + 100;
limitNorth = blockZ - 100;
limitSouth = blockZ + 200;
limitNorth = blockZ - 200;
waterLevel = blockY;
blocksPerY = new int[256];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#version 330

in vec3 colorModifier;
in vec2 texCoord;
in vec2 lightCoord;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#version 330 core
layout (points) in;
layout (triangle_strip, max_vertices = 30) out;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#version 330 core
// in_Position was bound to attribute index 0 and in_waterID was bound to attribute index 1
layout (location = 0) in vec3 in_Position;
layout (location = 1) in float light0;
layout (location = 2) in float light1;
Expand Down

0 comments on commit e7e6b53

Please sign in to comment.