Removed shaders.

They might come back in the future, but personally, I don't think
they're worth the headache right now. Even Minecraft doesn't use them,
really.
master
Caroline Bell 2019-09-21 20:15:16 -07:00
parent 94f3688de1
commit cc6f55dc24
6 changed files with 1 additions and 140 deletions

View File

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

View File

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

View File

@ -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");
}
}

View File

@ -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);"
};
}

View File

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

View File

@ -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);"
};
}