In order for your code to work, you would need to make the following changes (unified diff format):
@@ -30,6 +30,7 @@ import static org.lwjgl.opengl.ARBShaderObjects.*;
import static org.lwjgl.opengl.ARBVertexBufferObject.*;
import static org.lwjgl.opengl.ARBVertexShader.GL_VERTEX_SHADER_ARB;
import static org.lwjgl.opengl.ARBVertexShader.glEnableVertexAttribArrayARB;
+import static org.lwjgl.opengl.ARBVertexShader.glDisableVertexAttribArrayARB;
import static org.lwjgl.opengl.ARBVertexShader.glGetAttribLocationARB;
import static org.lwjgl.opengl.GL11.GL_LINEAR;
import static org.lwjgl.opengl.GL11.GL_LINEAR_MIPMAP_LINEAR;
@@ -298,9 +299,7 @@ public class WavefrontObjDemo {
glUseProgramObjectARB(cubemapProgram);
vertexAttribute = glGetAttribLocationARB(program, "aVertex");
- glEnableVertexAttribArrayARB(vertexAttribute);
normalAttribute = glGetAttribLocationARB(program, "aNormal");
- glEnableVertexAttribArrayARB(normalAttribute);
modelMatrixUniform = glGetUniformLocationARB(program, "uModelMatrix");
viewProjectionMatrixUniform = glGetUniformLocationARB(program, "uViewProjectionMatrix");
@@ -337,6 +336,7 @@ public class WavefrontObjDemo {
viewMatrix.setLookAt(viewPosition.x, viewPosition.y, viewPosition.z, 0f, 0f, 0f, 0f, 1f,
0f);
projectionMatrix.mul(viewMatrix, viewProjectionMatrix);
+ invViewProjMatrix.set(viewMatrix).setTranslation(0, 0, 0).mulLocal(projectionMatrix).invert(invViewProjMatrix);
glUseProgramObjectARB(cubemapProgram);
glUniformMatrix4fv(cubemap_invViewProjUniform, false, invViewProjMatrix.get(matrixBuffer));
@@ -354,7 +354,8 @@ public class WavefrontObjDemo {
drawCubemap();
glUseProgram(program);
-
+ glEnableVertexAttribArrayARB(vertexAttribute);
+ glEnableVertexAttribArrayARB(normalAttribute);
for (Model.Mesh mesh : model.meshes) {
glBindBuffer(GL_ARRAY_BUFFER, mesh.vertexArrayBuffer);
@@ -381,6 +382,8 @@ public class WavefrontObjDemo {
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.elementArrayBuffer);
glDrawElements(GL_TRIANGLES, mesh.elementCount, GL_UNSIGNED_INT, 0);
}
+ glDisableVertexAttribArrayARB(vertexAttribute);
+ glDisableVertexAttribArrayARB(normalAttribute);
}
But I also share the point of mudlee. You seem to be taking on a task which is way over your head and you must spend some more time learning OpenGL.
What you are currently doing is just stitching some snippets from lwjgl3-demos programs together and expecting that to work.