diff --git a/src/com/github/halotroop/litecraft/LiteCraftMain.java b/src/com/github/halotroop/litecraft/LiteCraftMain.java index e094374..0752f92 100644 --- a/src/com/github/halotroop/litecraft/LiteCraftMain.java +++ b/src/com/github/halotroop/litecraft/LiteCraftMain.java @@ -58,7 +58,7 @@ public class LiteCraftMain private void init() { - System.out.println("Initializing game."); + System.out.println("Initializing game..."); // Setup an error callback. The default implementation will print the error message in System.err. GLFWErrorCallback.createPrint(System.err).set(); // Initialize GLFW. Most GLFW functions will not work before doing this. @@ -66,7 +66,6 @@ public class LiteCraftMain // Configure GLFW window = new Window(width, height); - timer = new Timer(20); timer.addTickListener(tickListener); diff --git a/src/com/github/halotroop/litecraft/render/Renderer.java b/src/com/github/halotroop/litecraft/render/Renderer.java index e204910..47138d8 100644 --- a/src/com/github/halotroop/litecraft/render/Renderer.java +++ b/src/com/github/halotroop/litecraft/render/Renderer.java @@ -6,18 +6,14 @@ import org.lwjgl.opengl.GL20; import com.github.halotroop.litecraft.render.model.Model; import com.github.halotroop.litecraft.render.model.Vertex; -import com.github.halotroop.litecraft.render.shaders.BasicShader; -import com.github.halotroop.litecraft.render.shaders.Shader; public class Renderer { - private BasicShader basicShader; private Model model; public Renderer() { init(); - basicShader = new BasicShader(); model = new Model(); @@ -33,14 +29,12 @@ public class Renderer public void render() { - basicShader.bind(); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, model.getVBO()); GL20.glEnableVertexAttribArray(0); GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, Vertex.SIZE * 4, 0); GL20.glDrawArrays(GL20.GL_TRIANGLES, 0, model.getSize()); GL20.glDisableVertexAttribArray(0); GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0); - Shader.unbind(); } private void init() diff --git a/src/com/github/halotroop/litecraft/render/shaders/BasicShader.java b/src/com/github/halotroop/litecraft/render/shaders/BasicShader.java deleted file mode 100644 index 9e3eba4..0000000 --- a/src/com/github/halotroop/litecraft/render/shaders/BasicShader.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.halotroop.litecraft.render.shaders; - -public class BasicShader extends Shader -{ - public BasicShader() - { - super(); - } - - @Override - public void bindAttributes() - { - bindAttribute(0, "position"); - } -} \ No newline at end of file diff --git a/src/com/github/halotroop/litecraft/render/shaders/FragmentShaders.java b/src/com/github/halotroop/litecraft/render/shaders/FragmentShaders.java deleted file mode 100644 index 6392c63..0000000 --- a/src/com/github/halotroop/litecraft/render/shaders/FragmentShaders.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.github.halotroop.litecraft.render.shaders; - -public class FragmentShaders -{ - public static String[] basicFragment = - { - "#version 400", - "void main() {", - "gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);" - }; -} diff --git a/src/com/github/halotroop/litecraft/render/shaders/Shader.java b/src/com/github/halotroop/litecraft/render/shaders/Shader.java deleted file mode 100644 index 7db5153..0000000 --- a/src/com/github/halotroop/litecraft/render/shaders/Shader.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.github.halotroop.litecraft.render.shaders; - -import java.io.BufferedReader; - -import org.lwjgl.opengl.GL; -import org.lwjgl.opengl.GL20; - -public abstract class Shader -{ - private int program; - public Shader() - { - program = GL20.glCreateProgram(); - - if (program == 0) - noValidMemoryException(); - } - - private void addVertexShader(String text) - { addProgram(text, GL20.GL_VERTEX_SHADER); } - private void addFragmentShader(String text) - { addProgram(text, GL20.GL_FRAGMENT_SHADER); } - - protected void compileShader() - { - GL20.glLinkProgram(program); - - if (GL20.glGetProgrami(program, GL20.GL_LINK_STATUS) == 0) - compilationFailedException(program); - - GL20.glValidateProgram(program); - - if (GL20.glGetProgrami(program, GL20.GL_LINK_STATUS) == 0) - compilationFailedException(program); - - bindAttributes(); - } - - public abstract void bindAttributes(); - - protected void bindAttribute(int attribute, String variableName) - { - GL20.glBindAttribLocation(program, attribute, variableName); - } - - public void bind() - { - GL20.glUseProgram(program); - } - - public static void unbind() - { - GL20.glUseProgram(0); - } - - private void addProgram(String text, int type) - { - int shader = GL20.glCreateShader(type); - - if (shader == 0) - noValidMemoryException(); - - GL20.glShaderSource(shader, text); - GL20.glCompileShader(shader); - - if (GL20.glGetShaderi(shader, GL20.GL_COMPILE_STATUS) == 0) - compilationFailedException(shader); - - GL20.glAttachShader(program, shader); - } - - private void noValidMemoryException() - { - System.err.println("Shader creation failed! No valid memory!"); - System.exit(1); - } - - private void compilationFailedException(int id) - { - System.err.println(GL20.glGetShaderInfoLog(id, 1024)); - System.exit(1); - } - - private static String loadShader(String[] shaderStringArray) - { - String source = null; - for (String line : shaderStringArray) - { - source = source + line + "\n"; - } - - return source; - } -} \ No newline at end of file diff --git a/src/com/github/halotroop/litecraft/render/shaders/VertexShaders.java b/src/com/github/halotroop/litecraft/render/shaders/VertexShaders.java deleted file mode 100644 index db3a529..0000000 --- a/src/com/github/halotroop/litecraft/render/shaders/VertexShaders.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.github.halotroop.litecraft.render.shaders; - -public class VertexShaders -{ - public static String[] basicVertex = - { - "#version 400", - "layout (location = 0) in vec3 position", - "void main() {", - "gl_Position = vec4(postion, 1.0);" - }; -}