I'm been trying to make my engine work with the vertex array using triangle strips, but I run into a problem that I can't understand why it appears.
It looks like it drawing to many trinagles. The first picture below is taken from above and the second from below.
Edit: Img no longer on the server
Edit: Img no longer on the server
(The rectangle in the middle and to the side is just part of the GUI).
I'm using GL_CULL_FACE GL_CCW.
Init code:
// Create the vertex and texture cordinate arrayvertexArray = new float[mapWidth * mapWidth * 3];textArray = new float[mapWidth * mapWidth * 2];// Init the vertex and texture coord arrayfor(y = 0; y < (unsigned)mapWidth; y++){ for(x = 0; x < (unsigned)mapWidth; x++) { // Calculate the vertex vertexArray[j] = (float)x * scale; vertexArray[j+1] = bitmap->Image((mapWidth * y) + x) * heightScale; vertexArray[j+2] = (float)y * scale; // Calculate the texture coordinte textArray[i] = (float)x / (float)mapWidth; textArray[i+1] = -(float)y / (float)mapWidth; j += 3; i += 2; }}// Create the indices arrayindex = new unsigned short int[squareHeight * squareWidth * 2 + squareHeight + 1];j = 0; // Reset the counter var// Init the indices arrayfor(y = 0; y < squareHeight; y++){ if(forward == true) { for(x = 0; x < squareWidth; x++) { index[j] = ((mapWidth * y) + x); index[j+1] = ((mapWidth * y) + x) + mapWidth; j += 2; } } else { for(x = squareWidth; x > 0; x--) { index[j] = ((mapWidth * y) + x); index[j+1] = ((mapWidth * y) + x) + mapWidth; j += 2; } } index[j] = ((mapWidth * y) + x); j++; forward = !forward;}index[j] = ((mapWidth * squareHeight) + x); Drawing code: glVertexPointer(3, GL_FLOAT, 0, vertexArray);glTexCoordPointer(2, GL_FLOAT, 0, textArray);glDrawElements(GL_TRIANGLE_STRIP, squareWidth * squareHeight * 2 + squareHeight + 1, GL_UNSIGNED_SHORT, index);
What am I doing wrong? To me it looks like the row isn't reversed, and thus it jumps down to 0 and stars drawing the tringale form there, but I am reversing it. I been trying to figure it out for a long time now but I just cna't seem to nail it donw. So any help would be greatly aprishiated.
Thanks in advance
Leon Ljunggren
[edited by - Spearhawk on December 11, 2002 4:43:54 PM]