shader boiler plate
This commit is contained in:
1 parent
b154776905
commit
71f51f41f2
3 files changed
+53
-4
No files matched your search
@@ -14,7 +14,10 @@ public class Entity
|
||||
{
|
||||
OBJModel model;
|
||||
|
||||
ShaderProgram shader;
|
||||
public ShaderProgram shader;
|
||||
|
||||
private final int vaoId;
|
||||
private final int vboId;
|
||||
|
||||
public Entity(String object_file_path, String fragment_shader_path, String vertex_shader_path)
|
||||
{
|
||||
|
||||
@@ -95,13 +95,13 @@ public class Game
|
||||
// Setup world
|
||||
World world = new World();
|
||||
|
||||
// Add stuff to world
|
||||
world.addEntity(new Entity("/obs/cube.obj", "/shaders/shader.fraq", "/shaders/shader.vert"));
|
||||
|
||||
// Do open gl stuff
|
||||
GL.createCapabilities();
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
// Add stuff to world
|
||||
world.addEntity(new Entity("/obs/cube.obj", "/shaders/shader.fraq", "/shaders/shader.vert"));
|
||||
|
||||
// Main loop or something
|
||||
while ( !glfwWindowShouldClose(window) )
|
||||
{
|
||||
|
||||
@@ -79,5 +79,51 @@ public class ShaderProgram {
|
||||
}
|
||||
|
||||
// Set stuff
|
||||
public void setFloat(String name, float value) {
|
||||
glUniform1f(glGetUniformLocation(programId, name), value);
|
||||
}
|
||||
|
||||
public void setBool(String name, boolean value) {
|
||||
glUniform1i(glGetUniformLocation(programId, name), value ? 1 : 0);
|
||||
}
|
||||
|
||||
public void setInt(String name, int value) {
|
||||
glUniform1i(glGetUniformLocation(programId, name), value);
|
||||
}
|
||||
|
||||
public void setVec2(String name, float[] value) {
|
||||
glUniform2fv(glGetUniformLocation(programId, name), value);
|
||||
}
|
||||
|
||||
public void setVec2(String name, float x, float y) {
|
||||
glUniform2f(glGetUniformLocation(programId, name), x, y);
|
||||
}
|
||||
|
||||
public void setVec3(String name, float[] value) {
|
||||
glUniform3fv(glGetUniformLocation(programId, name), value);
|
||||
}
|
||||
|
||||
public void setVec3(String name, float x, float y, float z) {
|
||||
glUniform3f(glGetUniformLocation(programId, name), x, y, z);
|
||||
}
|
||||
|
||||
public void setVec4(String name, float[] value) {
|
||||
glUniform4fv(glGetUniformLocation(programId, name), value);
|
||||
}
|
||||
|
||||
public void setVec4(String name, float x, float y, float z, float w) {
|
||||
glUniform4f(glGetUniformLocation(programId, name), x, y, z, w);
|
||||
}
|
||||
|
||||
public void setMat2(String name, float[] mat) {
|
||||
glUniformMatrix2fv(glGetUniformLocation(programId, name), false, mat);
|
||||
}
|
||||
|
||||
public void setMat3(String name, float[] mat) {
|
||||
glUniformMatrix3fv(glGetUniformLocation(programId, name), false, mat);
|
||||
}
|
||||
|
||||
public void setMat4(String name, float[] mat) {
|
||||
glUniformMatrix4fv(glGetUniformLocation(programId, name), false, mat);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user