Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -456,17 +456,17 @@ private void setupShaderProgram() {
specifyVertexAttributes();

/* Set texture uniform */
int uniTex = program.getUniformLocation(ShaderLocations.TEX_IMAGE);
int uniTex = program.getUniformLocation(ShaderLocations.texImage);
program.setUniform(uniTex, 0);

/* Set model matrix to identity matrix */
Matrix4f model = new Matrix4f();
int uniModel = program.getUniformLocation(ShaderLocations.MODEL);
int uniModel = program.getUniformLocation(ShaderLocations.model);
program.setUniform(uniModel, model);

/* Set view matrix to identity matrix */
Matrix4f view = new Matrix4f();
int uniView = program.getUniformLocation(ShaderLocations.VIEW);
int uniView = program.getUniformLocation(ShaderLocations.view);
program.setUniform(uniView, view);

setProjection(width, height);
Expand All @@ -475,7 +475,7 @@ private void setupShaderProgram() {
public void setProjection(int width, int height) {
/* Set projection matrix to an orthographic projection */
Matrix4f projection = Matrix4f.orthographic(0f, width, 0f, height, -1f, 1f);
int uniformProjection = program.getUniformLocation(ShaderLocations.PROJECTION);
int uniformProjection = program.getUniformLocation(ShaderLocations.projection);
program.setUniform(uniformProjection, projection);
}

Expand All @@ -484,17 +484,17 @@ public void setProjection(int width, int height) {
*/
private void specifyVertexAttributes() {
/* Specify Vertex Pointer */
int posAttrib = program.getAttributeLocation(ShaderLocations.POSITION);
int posAttrib = program.getAttributeLocation(ShaderLocations.position);
program.enableVertexAttribute(posAttrib);
program.pointVertexAttribute(posAttrib, 2, 8 * Float.BYTES, 0);

/* Specify Color Pointer */
int colAttrib = program.getAttributeLocation(ShaderLocations.COLOR);
int colAttrib = program.getAttributeLocation(ShaderLocations.color);
program.enableVertexAttribute(colAttrib);
program.pointVertexAttribute(colAttrib, 4, 8 * Float.BYTES, 2 * Float.BYTES);

/* Specify Texture Pointer */
int texAttrib = program.getAttributeLocation(ShaderLocations.TEX_COORD);
int texAttrib = program.getAttributeLocation(ShaderLocations.texcoord);
program.enableVertexAttribute(texAttrib);
program.pointVertexAttribute(texAttrib, 2, 8 * Float.BYTES, 6 * Float.BYTES);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,12 @@ public void delete() {
}

public enum ShaderLocations {
TEX_IMAGE,
MODEL,
VIEW,
PROJECTION,
POSITION,
COLOR,
TEX_COORD;
texImage,
model,
view,
projection,
position,
color,
texcoord;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ public void enter() {
specifyVertexAttributes();

/* Get uniform location for the model matrix */
uniModel = program.getUniformLocation(ShaderLocations.MODEL);
uniModel = program.getUniformLocation(ShaderLocations.model);

/* Set view matrix to identity matrix */
Matrix4f view = new Matrix4f();
int uniView = program.getUniformLocation(ShaderLocations.VIEW);
int uniView = program.getUniformLocation(ShaderLocations.view);
program.setUniform(uniView, view);

/* Get width and height for calculating the ratio */
Expand All @@ -169,7 +169,7 @@ public void enter() {

/* Set projection matrix to an orthographic projection */
Matrix4f projection = Matrix4f.orthographic(-ratio, ratio, -1f, 1f, -1f, 1f);
int uniProjection = program.getUniformLocation(ShaderLocations.PROJECTION);
int uniProjection = program.getUniformLocation(ShaderLocations.projection);
program.setUniform(uniProjection, projection);
}

Expand All @@ -187,12 +187,12 @@ public void exit() {
*/
private void specifyVertexAttributes() {
/* Specify Vertex Pointer */
int posAttrib = program.getAttributeLocation(ShaderLocations.POSITION);
int posAttrib = program.getAttributeLocation(ShaderLocations.position);
program.enableVertexAttribute(posAttrib);
program.pointVertexAttribute(posAttrib, 3, 6 * Float.BYTES, 0);

/* Specify Color Pointer */
int colAttrib = program.getAttributeLocation(ShaderLocations.COLOR);
int colAttrib = program.getAttributeLocation(ShaderLocations.color);
program.enableVertexAttribute(colAttrib);
program.pointVertexAttribute(colAttrib, 3, 6 * Float.BYTES, 3 * Float.BYTES);
}
Expand Down