aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-04 13:06:36 +0200
committermakamys <makamys@outlook.com>2022-06-04 13:29:40 +0200
commitbc057b37b04b2650c8e9cb41406f3bdeb4cd72d1 (patch)
tree343dc9019bd1861098f63d5c52c01809792f16e2 /src/main/java/makamys
parent5bb8883539b952e4f418c278036b081efab0b83e (diff)
downloadNeodymium-bc057b37b04b2650c8e9cb41406f3bdeb4cd72d1.tar.gz
Neodymium-bc057b37b04b2650c8e9cb41406f3bdeb4cd72d1.tar.bz2
Neodymium-bc057b37b04b2650c8e9cb41406f3bdeb4cd72d1.zip
Reload shader if R is pressed
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRenderer.java69
1 files changed, 38 insertions, 31 deletions
diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
index c0f72be..d0de92b 100644
--- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java
+++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
@@ -244,6 +244,9 @@ public class LODRenderer {
if(Keyboard.isKeyDown(Keyboard.KEY_V) && !wasDown[Keyboard.KEY_V]) {
renderWorld = !renderWorld;
}
+ if(Keyboard.isKeyDown(Keyboard.KEY_R) && !wasDown[Keyboard.KEY_R]) {
+ loadShader();
+ }
if(Keyboard.isKeyDown(Keyboard.KEY_G) && !wasDown[Keyboard.KEY_G]) {
//LODChunk chunk = getLODChunk(9, -18);
//setMeshVisible(chunk.chunkMeshes[7], false, true);
@@ -395,37 +398,7 @@ public class LODRenderer {
public boolean init() {
Map<String, TextureAtlasSprite> uploadedSprites = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).mapUploadedSprites;
- int vertexShader;
- vertexShader = glCreateShader(GL_VERTEX_SHADER);
-
- glShaderSource(vertexShader, Util.readFile("shaders/chunk.vert"));
- glCompileShader(vertexShader);
-
- if(glGetShaderi(vertexShader, GL_COMPILE_STATUS) == 0) {
- System.out.println("Error compiling vertex shader: " + glGetShaderInfoLog(vertexShader, 256));
- }
-
- int fragmentShader;
- fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
-
- glShaderSource(fragmentShader, Util.readFile("shaders/chunk.frag"));
- glCompileShader(fragmentShader);
-
- if(glGetShaderi(fragmentShader, GL_COMPILE_STATUS) == 0) {
- System.out.println("Error compiling fragment shader: " + glGetShaderInfoLog(fragmentShader, 256));
- }
-
- shaderProgram = glCreateProgram();
- glAttachShader(shaderProgram, vertexShader);
- glAttachShader(shaderProgram, fragmentShader);
- glLinkProgram(shaderProgram);
-
- if(glGetProgrami(shaderProgram, GL_LINK_STATUS) == 0) {
- System.out.println("Error linking shader: " + glGetShaderInfoLog(shaderProgram, 256));
- }
-
- glDeleteShader(vertexShader);
- glDeleteShader(fragmentShader);
+ loadShader();
VAO = glGenVertexArrays();
glBindVertexArray(VAO);
@@ -460,6 +433,40 @@ public class LODRenderer {
return true;
}
+ private void loadShader() {
+ int vertexShader;
+ vertexShader = glCreateShader(GL_VERTEX_SHADER);
+
+ glShaderSource(vertexShader, Util.readFile("shaders/chunk.vert"));
+ glCompileShader(vertexShader);
+
+ if(glGetShaderi(vertexShader, GL_COMPILE_STATUS) == 0) {
+ System.out.println("Error compiling vertex shader: " + glGetShaderInfoLog(vertexShader, 256));
+ }
+
+ int fragmentShader;
+ fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
+
+ glShaderSource(fragmentShader, Util.readFile("shaders/chunk.frag"));
+ glCompileShader(fragmentShader);
+
+ if(glGetShaderi(fragmentShader, GL_COMPILE_STATUS) == 0) {
+ System.out.println("Error compiling fragment shader: " + glGetShaderInfoLog(fragmentShader, 256));
+ }
+
+ shaderProgram = glCreateProgram();
+ glAttachShader(shaderProgram, vertexShader);
+ glAttachShader(shaderProgram, fragmentShader);
+ glLinkProgram(shaderProgram);
+
+ if(glGetProgrami(shaderProgram, GL_LINK_STATUS) == 0) {
+ System.out.println("Error linking shader: " + glGetShaderInfoLog(shaderProgram, 256));
+ }
+
+ glDeleteShader(vertexShader);
+ glDeleteShader(fragmentShader);
+ }
+
public void destroy() {
onSave();