I'm currently working on a project using the lwjgl. I have a working world that has textures and vertexes in Vertex buffer objects. The next step I'm trying to implement is lighting. I have the normals for my world defined and have set up a VBO for them. However, it causes the program to crash.
This is the code I use to set up the normal VBO, it is the same setup I use for the texture and vertex VBO's that I know work.
float norms = new float[normalsList.size()];
for (int i = 0; i < normalsList.size(); i++)
norms[i] = normalsList.get(i);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, 4 * norms.length, GL15.GL_DYNAMIC_DRAW);
ByteBuffer byteBuffer3 = GL15.glMapBuffer(GL15.GL_ARRAY_BUFFER, GL15.GL_WRITE_ONLY, 4 * norms.length, null);
nBuffer = byteBuffer3.order(ByteOrder.nativeOrder()).asFloatBuffer();
This is the code I use to draw my VBO objects, changing the values for glNormalPointer has changed where the program crashes, but it always does crash. The crash does not happen if I disable lighting.
GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);
GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.cubeVerts.length / (3));
I know that I need to disable GL_LIGHTING for 2d drawing, I just don't have that for my test world right now.
Is there some function call I am missing or variable I need to supply?
Any help is appreciated!