JoeyDeVries/LearnOpenGL

Incorrect Vertex Winding in src/4.advanced_opengl/

Andrew-Hinkle opened this issue · 4 comments

I noticed a minor issue with the vertex array for the cubes in the advanced opengl section are ordered wrong, which causes a minor visual glitch for texturing. I found that the last 2 vertices in the cubeVertices array are swapped, so the winding order causes the texture to draw incorrectly.

The last block over vertex data in the array should be:
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f

I didn't notice any visual artifacts on the original winding order (same on getting started section). Which specific chapter did it break for you, do you have a screenshot for what you've been seeing as well?

Hi Joey,

I noticed the issue on the depth testing, stencil testing and blending chapters, but I didn't notice any issues before the advanced opengl section.

Here is what I'm seeing using the original vertex array:
original

Here is what I see when I swap the last two vertices' order:
fixed

I swapped to a uv grid texture to diagnose what was happening. Its entirely possible I have some other issue, but I wanted to bring it up in case anyone had a similar issue to what I saw.

Hmm, just checked with a different texture as well on my end, but it all looks correct here. Since I'm not sure what's happening here I can't put your changes in, but let's leave this one open and see if others have similar issues. Maybe from that we can figure out the pattern.

Sounds good, thanks for checking it out!