Last active
October 9, 2015 12:28
-
-
Save jblocksom/3505997 to your computer and use it in GitHub Desktop.
OpenGL sample texture coordinates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // three xyz coordinates, three normal coordinates, two texture coordinates * | |
| // six vertices per face * | |
| // six faces per cube | |
| GLfloat gCubeVertexData[(3 + 3 + 2) * 6 * 6] = | |
| { | |
| // Data layout for each line below is: | |
| // positionX, positionY, positionZ, normalX, normalY, normalZ, texCoord0S, texCoord0T, | |
| 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, | |
| 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, | |
| 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, | |
| 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, | |
| 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, | |
| 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, | |
| 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, | |
| -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, | |
| 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, | |
| 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, | |
| -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, | |
| -0.5f, 0.5f, 0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, | |
| -0.5f, 0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, | |
| -0.5f, -0.5f, -0.5f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f,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.0f, 1.0f, 1.0f, | |
| -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, | |
| -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If enable glEnable(GL_CULL_FACE); then second triangle will be culled because of the incorrect vertex order. To fix it you should replace lines 11, 12 and 13 with this: