I know what glFrontFace does. I kinda made it seem like I didn't but for whatever reason it didn't work. GL_DEPTH_TEST is enabled too.
Yes, I know that is not opengl 3.2 core code. I did it to be clear on where the light is positioned.
I have it on compatibility mode and I avoid it in pretty much all my code except that one bit of code. I didn't feel like trying to create some type of buffer for one point and etc although I probably could have just used the geometry shader to pull that off. Even though I'm using the compatibility mode this doesn't stop the shader from working. Also if I try to use the core opengl crashes if I use glSubBuffer which I find really weird. (nvidia 9500 gt)
I made 2 separate buffers. 1 for the position data and another for the normal data because I didn't want to think about offsetting the data but I do make sure they match.
This should be okay right? I might have missed something that has completely skipped my mind since I don't really run into this situation.
//Cube Data//Bottom vertices[0] = vector_math::Vec3<float>(-1.0f, 1.0f, -1.0f); normals[0] = vector_math::Vec3<float>(0.0f, 0.0f, -1.0f); vertices[1] = vector_math::Vec3<float>( 1.0f, -1.0f, -1.0f); normals[1] = vector_math::Vec3<float>(0.0f, 0.0f, -1.0f); vertices[2] = vector_math::Vec3<float>(-1.0f, -1.0f, -1.0f); normals[2] = vector_math::Vec3<float>(0.0f, 0.0f, -1.0f); vertices[3] = vector_math::Vec3<float>(-1.0f, 1.0f, -1.0f); normals[3] = vector_math::Vec3<float>(0.0f, 0.0f, -1.0f); vertices[4] = vector_math::Vec3<float>( 1.0f, 1.0f, -1.0f); normals[4] = vector_math::Vec3<float>(0.0f, 0.0f, -1.0f); vertices[5] = vector_math::Vec3<float>( 1.0f, -1.0f, -1.0f); normals[5] = vector_math::Vec3<float>(0.0f, 0.0f, -1.0f);//Top vertices[6] = vector_math::Vec3<float>(-1.0f, 1.0f, 1.0f); normals[6] = vector_math::Vec3<float>(0.0f, 0.0f, 1.0f); vertices[7] = vector_math::Vec3<float>( 1.0f, -1.0f, 1.0f); normals[7] = vector_math::Vec3<float>(0.0f, 0.0f, 1.0f); vertices[8] = vector_math::Vec3<float>(-1.0f, -1.0f, 1.0f); normals[8] = vector_math::Vec3<float>(0.0f, 0.0f, 1.0f); vertices[9] = vector_math::Vec3<float>(-1.0f, 1.0f, 1.0f); normals[9] = vector_math::Vec3<float>(0.0f, 0.0f, 1.0f); vertices[10] = vector_math::Vec3<float>( 1.0f, 1.0f, 1.0f); normals[10] = vector_math::Vec3<float>(0.0f, 0.0f, 1.0f); vertices[11] = vector_math::Vec3<float>( 1.0f, -1.0f, 1.0f); normals[11] = vector_math::Vec3<float>(0.0f, 0.0f, 1.0f);//Left vertices[12] = vector_math::Vec3<float>(-1.0f, -1.0f, 1.0f); normals[12] = vector_math::Vec3<float>(0.0f, -1.0f, 0.0f); vertices[13] = vector_math::Vec3<float>( 1.0f, -1.0f, -1.0f); normals[13] = vector_math::Vec3<float>(0.0f, -1.0f, 0.0f); vertices[14] = vector_math::Vec3<float>(-1.0f, -1.0f, -1.0f); normals[14] = vector_math::Vec3<float>(0.0f, -1.0f, 0.0f); vertices[15] = vector_math::Vec3<float>(-1.0f, -1.0f, 1.0f); normals[15] = vector_math::Vec3<float>(0.0f, -1.0f, 0.0f); vertices[16] = vector_math::Vec3<float>( 1.0f, -1.0f, 1.0f); normals[16] = vector_math::Vec3<float>(0.0f, -1.0f, 0.0f); vertices[17] = vector_math::Vec3<float>( 1.0f, -1.0f, -1.0f); normals[17] = vector_math::Vec3<float>(0.0f, -1.0f, 0.0f);//Right vertices[18] = vector_math::Vec3<float>(-1.0f, 1.0f, 1.0f); normals[18] = vector_math::Vec3<float>(0.0f, 1.0f, 0.0f); vertices[19] = vector_math::Vec3<float>( 1.0f, 1.0f, -1.0f); normals[19] = vector_math::Vec3<float>(0.0f, 1.0f, 0.0f); vertices[20] = vector_math::Vec3<float>(-1.0f, 1.0f, -1.0f); normals[20] = vector_math::Vec3<float>(0.0f, 1.0f, 0.0f); vertices[21] = vector_math::Vec3<float>(-1.0f, 1.0f, 1.0f); normals[21] = vector_math::Vec3<float>(0.0f, 1.0f, 0.0f); vertices[22] = vector_math::Vec3<float>( 1.0f, 1.0f, 1.0f); normals[22] = vector_math::Vec3<float>(0.0f, 1.0f, 0.0f); vertices[23] = vector_math::Vec3<float>( 1.0f, 1.0f, -1.0f); normals[23] = vector_math::Vec3<float>(0.0f, 1.0f, 0.0f);//Back vertices[24] = vector_math::Vec3<float>(-1.0f, -1.0f, 1.0f); normals[24] = vector_math::Vec3<float>(-1.0f, 0.0f, 0.0f); vertices[25] = vector_math::Vec3<float>(-1.0f, 1.0f, -1.0f); normals[25] = vector_math::Vec3<float>(-1.0f, 0.0f, 0.0f); vertices[26] = vector_math::Vec3<float>(-1.0f, -1.0f, -1.0f); normals[26] = vector_math::Vec3<float>(-1.0f, 0.0f, 0.0f); vertices[27] = vector_math::Vec3<float>(-1.0f, -1.0f, 1.0f); normals[27] = vector_math::Vec3<float>(-1.0f, 0.0f, 0.0f); vertices[28] = vector_math::Vec3<float>(-1.0f, 1.0f, 1.0f); normals[28] = vector_math::Vec3<float>(-1.0f, 0.0f, 0.0f); vertices[29] = vector_math::Vec3<float>(-1.0f, 1.0f, -1.0f); normals[29] = vector_math::Vec3<float>(-1.0f, 0.0f, 0.0f);//Front vertices[30] = vector_math::Vec3<float>( 1.0f, -1.0f, 1.0f); normals[30] = vector_math::Vec3<float>( 1.0f, 0.0f, 0.0f); vertices[31] = vector_math::Vec3<float>( 1.0f, 1.0f, -1.0f); normals[31] = vector_math::Vec3<float>( 1.0f, 0.0f, 0.0f); vertices[32] = vector_math::Vec3<float>( 1.0f, -1.0f, -1.0f); normals[32] = vector_math::Vec3<float>( 1.0f, 0.0f, 0.0f); vertices[33] = vector_math::Vec3<float>( 1.0f, -1.0f, 1.0f); normals[33] = vector_math::Vec3<float>( 1.0f, 0.0f, 0.0f); vertices[34] = vector_math::Vec3<float>( 1.0f, 1.0f, 1.0f); normals[34] = vector_math::Vec3<float>( 1.0f, 0.0f, 0.0f); vertices[35] = vector_math::Vec3<float>( 1.0f, 1.0f, -1.0f); normals[35] = vector_math::Vec3<float>( 1.0f, 0.0f, 0.0f); for(int i=0; i<36; i++) indices = i; glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, normalBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(normals), normals, GL_STATIC_DRAW); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iBuffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW ); glBindVertexArray(vaoBuffer); glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer); glVertexAttribPointer(attribVertex, 3, GL_FLOAT, GL_FALSE, sizeof(vector_math::Vec3<float>), 0); glBindBuffer(GL_ARRAY_BUFFER, normalBuffer); glVertexAttribPointer(attribNormal, 3, GL_FLOAT, GL_FALSE, sizeof(vector_math::Vec3<float>), 0); glEnableVertexAttribArray(attribVertex); glEnableVertexAttribArray(attribNormal); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, iBuffer); glBindVertexArray(0);