Showing the changes to interface/src/renderer/GeometryCache.cpp (1 of 3 files). Show all
Unified · Split
| @@ -169,18 +169,23 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 168 unmodified lines | ||
| 169 | 169 | int vertices = (slices + 1) * stacks; |
| 170 | 170 | int indices = 2 * 3 * slices * (stacks - 1); |
| 171 | 171 | if (vbo.first == 0) { |
| 172 | − GLfloat* vertexData = new GLfloat[vertices * 3]; | |
| 172 | + GLfloat* vertexData = new GLfloat[vertices * 2 * 3]; | |
| 173 | 173 | GLfloat* vertex = vertexData; |
| 174 | 174 | for (int i = 0; i <= (stacks - 1); i++) { |
| 175 | 175 | float y = (float)i / (stacks - 1); |
| 176 | − float radius = 1.0f; | |
| 177 | 176 | |
| 178 | 177 | for (int j = 0; j <= slices; j++) { |
| 179 | 178 | float theta = 3 * PIf / 2 + PIf * j / slices; |
| 180 | 179 | |
| 181 | − *(vertex++) = sinf(theta) * radius; | |
| 180 | + //normals | |
| 181 | + *(vertex++) = sinf(theta); | |
| 182 | + *(vertex++) = 0; | |
| 183 | + *(vertex++) = cosf(theta); | |
| 184 | + | |
| 185 | + // vertices | |
| 186 | + *(vertex++) = sinf(theta); | |
| 182 | 187 | *(vertex++) = y; |
| 183 | − *(vertex++) = cosf(theta) * radius; | |
| 188 | + *(vertex++) = cosf(theta); | |
| 184 | 189 | } |
| 185 | 190 | } |
| 186 | 191 | |
| @@ -196,7 +201,7 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 9 unmodified lines | ||
| 196 | 201 | GLushort bottom = i * (slices + 1); |
| 197 | 202 | GLushort top = bottom + slices + 1; |
| 198 | 203 | for (int j = 0; j < slices; j++) { |
| 199 | − int next = (j + 1) % slices; | |
| 204 | + int next = j + 1; | |
| 200 | 205 | |
| 201 | 206 | *(index++) = bottom + j; |
| 202 | 207 | *(index++) = top + next; |
| @@ -220,9 +225,9 @@ void GeometryCache::renderHalfCylinder(int slices, int stacks) { · 17 unmodified lines | ||
| 220 | 225 | } |
| 221 | 226 | glEnableClientState(GL_VERTEX_ARRAY); |
| 222 | 227 | glEnableClientState(GL_NORMAL_ARRAY); |
| 223 | − | |
| 224 | − glVertexPointer(3, GL_FLOAT, 0, 0); | |
| 225 | − glNormalPointer(GL_FLOAT, 0, 0); | |
| 228 | + | |
| 229 | + glNormalPointer(GL_FLOAT, 6 * sizeof(float), 0); | |
| 230 | + glVertexPointer(3, GL_FLOAT, 6 * sizeof(float), 3 * sizeof(float)); | |
| 226 | 231 | |
| 227 | 232 | glDrawRangeElementsEXT(GL_TRIANGLES, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0); |
| 228 | 233 | |