| 30 | { |
| 31 | |
| 32 | void generateGridIndices(std::vector<unsigned int>& indices, |
| 33 | unsigned short rows, unsigned short cols) |
| 34 | { |
| 35 | const int numDegens = 2 * (rows - 2); |
| 36 | const int verticesPerStrip = 2 * cols; |
| 37 | |
| 38 | //reserve the size of vector |
| 39 | indices.reserve(verticesPerStrip + numDegens); |
| 40 | |
| 41 | for (int r = 0; r < (rows-1); ++r) { |
| 42 | if (r > 0) { |
| 43 | // repeat first vertex for degenerate triangle |
| 44 | indices.push_back(r*rows); |
| 45 | } |
| 46 | |
| 47 | for (int c = 0; c < cols; ++c) { |
| 48 | // One part of the strip |
| 49 | indices.push_back(r*rows + c); |
| 50 | indices.push_back((r+1)*rows + c); |
| 51 | } |
| 52 | |
| 53 | if (r < (rows-2)) { |
| 54 | // repeat last vertex for degenerate triangle |
| 55 | indices.push_back(((r + 1) * rows) + (cols - 1)); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | void surface_impl::bindResources(const int pWindowId) |
| 61 | { |