Commit a56865a02b14746e3c2fe9c1c5d2334c6b9c7336
1 parent
efe1e8ca
Changes following "Remove geometry scvene object"
Change-Id: I8138d652252f76ef24becc0fcfce3cef15321cad
Showing
7 changed files
with
23 additions
and
95 deletions
examples/line-mesh/line-mesh-example.cpp
| ... | ... | @@ -62,43 +62,11 @@ void main() |
| 62 | 62 | } |
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | -PropertyBuffer CreateIndexBuffer( Geometry::GeometryType geometryType ) | |
| 66 | -{ | |
| 67 | - // Create indices | |
| 68 | - const unsigned int indexDataLines[] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 0 }; | |
| 69 | - const unsigned int indexDataLoops[] = { 0, 1, 2, 3, 4 }; | |
| 70 | - const unsigned int indexDataStrips[] = { 0, 1, 2, 3, 4, 0 }; | |
| 71 | - | |
| 72 | - // Create index buffer if doesn't exist | |
| 73 | - Property::Map indexFormat; | |
| 74 | - indexFormat["indices"] = Property::INTEGER; | |
| 75 | - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); | |
| 76 | - | |
| 77 | - // Update buffer | |
| 78 | - switch( geometryType ) | |
| 79 | - { | |
| 80 | - case Geometry::LINES: | |
| 81 | - { | |
| 82 | - indices.SetData( indexDataLines, sizeof(indexDataLines)/sizeof(indexDataLines[0]) ); | |
| 83 | - break; | |
| 84 | - } | |
| 85 | - case Geometry::LINE_LOOP: | |
| 86 | - { | |
| 87 | - indices.SetData( indexDataLoops, sizeof(indexDataLoops)/sizeof(indexDataLoops[0]) ); | |
| 88 | - break; | |
| 89 | - } | |
| 90 | - case Geometry::LINE_STRIP: | |
| 91 | - { | |
| 92 | - indices.SetData( indexDataStrips, sizeof(indexDataStrips)/sizeof(indexDataStrips[0]) ); | |
| 93 | - break; | |
| 94 | - } | |
| 95 | - default: // this will never happen, but compilers yells | |
| 96 | - { | |
| 97 | - } | |
| 98 | - } | |
| 99 | - | |
| 100 | - return indices; | |
| 101 | -} | |
| 65 | +const unsigned short indexLines[] = { 0, 1, 1, 2, 2, 3, 3, 4, 4, 0 }; | |
| 66 | +const unsigned short indexLoop[] = { 0, 1, 2, 3, 4 }; | |
| 67 | +const unsigned short indexStrip[] = { 0, 1, 2, 3, 4, 0 }; | |
| 68 | +const unsigned short* indices[3] = { &indexLines[0], &indexLoop[0], &indexStrip[0] }; | |
| 69 | +const unsigned int indicesSize[3] = { sizeof(indexLines)/sizeof(indexLines[0]), sizeof(indexLoop)/sizeof(indexLoop[0]), sizeof(indexStrip)/sizeof(indexStrip[0])}; | |
| 102 | 70 | |
| 103 | 71 | Geometry CreateGeometry() |
| 104 | 72 | { |
| ... | ... | @@ -127,13 +95,11 @@ Geometry CreateGeometry() |
| 127 | 95 | PropertyBuffer pentagonVertices = PropertyBuffer::New( pentagonVertexFormat ); |
| 128 | 96 | pentagonVertices.SetData(pentagonVertexData, 5); |
| 129 | 97 | |
| 130 | - // Create indices | |
| 131 | - PropertyBuffer indices = CreateIndexBuffer( Geometry::LINES ); | |
| 132 | 98 | |
| 133 | 99 | // Create the geometry object |
| 134 | 100 | Geometry pentagonGeometry = Geometry::New(); |
| 135 | 101 | pentagonGeometry.AddVertexBuffer( pentagonVertices ); |
| 136 | - pentagonGeometry.SetIndexBuffer( indices ); | |
| 102 | + pentagonGeometry.SetIndexBuffer( indices[0], indicesSize[0] ); | |
| 137 | 103 | pentagonGeometry.SetGeometryType( Geometry::LINES ); |
| 138 | 104 | return pentagonGeometry; |
| 139 | 105 | } |
| ... | ... | @@ -316,8 +282,7 @@ public: |
| 316 | 282 | index = 2; |
| 317 | 283 | } |
| 318 | 284 | |
| 319 | - PropertyBuffer indices = CreateIndexBuffer( geomTypes[ index ] ); | |
| 320 | - mGeometry.SetIndexBuffer( indices ); | |
| 285 | + mGeometry.SetIndexBuffer( indices[index], indicesSize[index] ); | |
| 321 | 286 | mGeometry.SetGeometryType( geomTypes[ index ] ); |
| 322 | 287 | |
| 323 | 288 | return true; | ... | ... |
examples/mesh-sorting/mesh-sorting-example.cpp
| ... | ... | @@ -102,16 +102,12 @@ Geometry CreateGeometry() |
| 102 | 102 | texturedQuadVertices.SetData( texturedQuadVertexData, 4 ); |
| 103 | 103 | |
| 104 | 104 | // Create indices |
| 105 | - unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 }; | |
| 106 | - Property::Map indexFormat; | |
| 107 | - indexFormat["indices"] = Property::INTEGER; | |
| 108 | - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); | |
| 109 | - indices.SetData( indexData, 6 ); | |
| 105 | + unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 }; | |
| 110 | 106 | |
| 111 | 107 | // Create the geometry object |
| 112 | 108 | Geometry texturedQuadGeometry = Geometry::New(); |
| 113 | 109 | texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices ); |
| 114 | - texturedQuadGeometry.SetIndexBuffer( indices ); | |
| 110 | + texturedQuadGeometry.SetIndexBuffer( &indexData[0], sizeof(indexData)/sizeof(unsigned short) ); | |
| 115 | 111 | |
| 116 | 112 | return texturedQuadGeometry; |
| 117 | 113 | } | ... | ... |
examples/metaball-explosion/metaball-explosion-example.cpp
| ... | ... | @@ -373,8 +373,6 @@ Geometry MetaballExplosionController::CreateGeometry() |
| 373 | 373 | { Vector2(1.0f, 1.0f * aspect) } |
| 374 | 374 | }; |
| 375 | 375 | |
| 376 | - int indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 377 | - | |
| 378 | 376 | unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); |
| 379 | 377 | |
| 380 | 378 | //Vertices |
| ... | ... | @@ -390,17 +388,14 @@ Geometry MetaballExplosionController::CreateGeometry() |
| 390 | 388 | textureVertices.SetData( textures, numberOfVertices ); |
| 391 | 389 | |
| 392 | 390 | //Indices |
| 393 | - Property::Map indicesVertexFormat; | |
| 394 | - indicesVertexFormat["aIndices"] = Property::INTEGER; | |
| 395 | - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); | |
| 396 | - indicesToVertices.SetData( indices, 6 ); | |
| 391 | + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 397 | 392 | |
| 398 | 393 | // Create the geometry object |
| 399 | 394 | Geometry texturedQuadGeometry = Geometry::New(); |
| 400 | 395 | texturedQuadGeometry.AddVertexBuffer( positionVertices ); |
| 401 | 396 | texturedQuadGeometry.AddVertexBuffer( textureVertices ); |
| 402 | 397 | |
| 403 | - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); | |
| 398 | + texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) ); | |
| 404 | 399 | |
| 405 | 400 | return texturedQuadGeometry; |
| 406 | 401 | } |
| ... | ... | @@ -431,8 +426,6 @@ Geometry MetaballExplosionController::CreateGeometryComposition() |
| 431 | 426 | { Vector2(1.0f, 1.0f) } |
| 432 | 427 | }; |
| 433 | 428 | |
| 434 | - int indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 435 | - | |
| 436 | 429 | unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); |
| 437 | 430 | |
| 438 | 431 | //Vertices |
| ... | ... | @@ -448,17 +441,14 @@ Geometry MetaballExplosionController::CreateGeometryComposition() |
| 448 | 441 | textureVertices.SetData( textures, numberOfVertices ); |
| 449 | 442 | |
| 450 | 443 | //Indices |
| 451 | - Property::Map indicesVertexFormat; | |
| 452 | - indicesVertexFormat["aIndices"] = Property::INTEGER; | |
| 453 | - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); | |
| 454 | - indicesToVertices.SetData( indices, 6 ); | |
| 444 | + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 455 | 445 | |
| 456 | 446 | // Create the geometry object |
| 457 | 447 | Geometry texturedQuadGeometry = Geometry::New(); |
| 458 | 448 | texturedQuadGeometry.AddVertexBuffer( positionVertices ); |
| 459 | 449 | texturedQuadGeometry.AddVertexBuffer( textureVertices ); |
| 460 | 450 | |
| 461 | - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); | |
| 451 | + texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) ); | |
| 462 | 452 | |
| 463 | 453 | return texturedQuadGeometry; |
| 464 | 454 | } | ... | ... |
examples/metaball-refrac/metaball-refrac-example.cpp
| ... | ... | @@ -322,8 +322,6 @@ Geometry MetaballRefracController::CreateGeometry() |
| 322 | 322 | { Vector3(0.0f, 0.0f, 1.0f) } |
| 323 | 323 | }; |
| 324 | 324 | |
| 325 | - int indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 326 | - | |
| 327 | 325 | unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); |
| 328 | 326 | |
| 329 | 327 | //Vertices |
| ... | ... | @@ -345,11 +343,7 @@ Geometry MetaballRefracController::CreateGeometry() |
| 345 | 343 | normalVertices.SetData( normals, numberOfVertices ); |
| 346 | 344 | |
| 347 | 345 | //Indices |
| 348 | - Property::Map indicesVertexFormat; | |
| 349 | - indicesVertexFormat["aIndices"] = Property::INTEGER; | |
| 350 | - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); | |
| 351 | - indicesToVertices.SetData( indices, 6 ); | |
| 352 | - | |
| 346 | + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 353 | 347 | |
| 354 | 348 | // Create the geometry object |
| 355 | 349 | Geometry texturedQuadGeometry = Geometry::New(); |
| ... | ... | @@ -357,7 +351,7 @@ Geometry MetaballRefracController::CreateGeometry() |
| 357 | 351 | texturedQuadGeometry.AddVertexBuffer( textureVertices ); |
| 358 | 352 | texturedQuadGeometry.AddVertexBuffer( normalVertices ); |
| 359 | 353 | |
| 360 | - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); | |
| 354 | + texturedQuadGeometry.SetIndexBuffer ( &indices[0], 6 ); | |
| 361 | 355 | |
| 362 | 356 | return texturedQuadGeometry; |
| 363 | 357 | } |
| ... | ... | @@ -398,8 +392,6 @@ Geometry MetaballRefracController::CreateGeometryComposition() |
| 398 | 392 | { Vector3(0.0f, 0.0f, 1.0f) } |
| 399 | 393 | }; |
| 400 | 394 | |
| 401 | - int indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 402 | - | |
| 403 | 395 | unsigned int numberOfVertices = sizeof(vertices)/sizeof(VertexPosition); |
| 404 | 396 | |
| 405 | 397 | //Vertices |
| ... | ... | @@ -421,10 +413,7 @@ Geometry MetaballRefracController::CreateGeometryComposition() |
| 421 | 413 | normalVertices.SetData( normals, numberOfVertices ); |
| 422 | 414 | |
| 423 | 415 | //Indices |
| 424 | - Property::Map indicesVertexFormat; | |
| 425 | - indicesVertexFormat["aIndices"] = Property::INTEGER; | |
| 426 | - PropertyBuffer indicesToVertices = PropertyBuffer::New( indicesVertexFormat ); | |
| 427 | - indicesToVertices.SetData( indices, 6 ); | |
| 416 | + unsigned short indices[] = { 0, 3, 1, 0, 2, 3 }; | |
| 428 | 417 | |
| 429 | 418 | // Create the geometry object |
| 430 | 419 | Geometry texturedQuadGeometry = Geometry::New(); |
| ... | ... | @@ -432,7 +421,7 @@ Geometry MetaballRefracController::CreateGeometryComposition() |
| 432 | 421 | texturedQuadGeometry.AddVertexBuffer( textureVertices ); |
| 433 | 422 | texturedQuadGeometry.AddVertexBuffer( normalVertices ); |
| 434 | 423 | |
| 435 | - texturedQuadGeometry.SetIndexBuffer ( indicesToVertices ); | |
| 424 | + texturedQuadGeometry.SetIndexBuffer ( &indices[0], sizeof( indices )/ sizeof( indices[0] ) ); | |
| 436 | 425 | |
| 437 | 426 | return texturedQuadGeometry; |
| 438 | 427 | } | ... | ... |
examples/new-window/new-window-example.cpp
| ... | ... | @@ -450,16 +450,12 @@ Geometry NewWindowController::CreateMeshGeometry() |
| 450 | 450 | vertices.SetData( vertexData, 5 ); |
| 451 | 451 | |
| 452 | 452 | // Specify all the faces |
| 453 | - unsigned int indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 }; | |
| 454 | - Property::Map indexFormat; | |
| 455 | - indexFormat["indices"] = Property::INTEGER; | |
| 456 | - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); | |
| 457 | - indices.SetData( indexData, 12 ); | |
| 453 | + unsigned short indexData[12] = { 0,1,3,0,2,4,0,3,4,0,2,1 }; | |
| 458 | 454 | |
| 459 | 455 | // Create the geometry object |
| 460 | 456 | Geometry geometry = Geometry::New(); |
| 461 | 457 | geometry.AddVertexBuffer( vertices ); |
| 462 | - geometry.SetIndexBuffer( indices ); | |
| 458 | + geometry.SetIndexBuffer( &indexData[0], 12 ); | |
| 463 | 459 | |
| 464 | 460 | return geometry; |
| 465 | 461 | } | ... | ... |
examples/radial-menu/radial-sweep-view-impl.cpp
| ... | ... | @@ -330,15 +330,11 @@ void RadialSweepViewImpl::CreateStencil( Radian initialSector ) |
| 330 | 330 | PropertyBuffer vertices = PropertyBuffer::New( vertexFormat ); |
| 331 | 331 | vertices.SetData( vertexData, 7u ); |
| 332 | 332 | |
| 333 | - unsigned int indexData[15] = { 0,1,2,0,2,3,0,3,4,0,4,5,0,5,6 }; | |
| 334 | - Property::Map indexFormat; | |
| 335 | - indexFormat["indices"] = Property::INTEGER; | |
| 336 | - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); | |
| 337 | - indices.SetData( indexData, 15u ); | |
| 333 | + unsigned short indexData[15] = { 0,1,2,0,2,3,0,3,4,0,4,5,0,5,6 }; | |
| 338 | 334 | |
| 339 | 335 | Geometry meshGeometry = Geometry::New(); |
| 340 | 336 | meshGeometry.AddVertexBuffer( vertices ); |
| 341 | - meshGeometry.SetIndexBuffer( indices ); | |
| 337 | + meshGeometry.SetIndexBuffer( &indexData[0], sizeof( indexData )/sizeof(indexData[0]) ); | |
| 342 | 338 | |
| 343 | 339 | // Create shader |
| 344 | 340 | std::ostringstream vertexShaderStringStream; | ... | ... |
examples/textured-mesh/textured-mesh-example.cpp
| ... | ... | @@ -79,16 +79,12 @@ Geometry CreateGeometry() |
| 79 | 79 | texturedQuadVertices.SetData( texturedQuadVertexData, 4 ); |
| 80 | 80 | |
| 81 | 81 | // Create indices |
| 82 | - unsigned int indexData[6] = { 0, 3, 1, 0, 2, 3 }; | |
| 83 | - Property::Map indexFormat; | |
| 84 | - indexFormat["indices"] = Property::INTEGER; | |
| 85 | - PropertyBuffer indices = PropertyBuffer::New( indexFormat ); | |
| 86 | - indices.SetData( indexData, sizeof(indexData)/sizeof(indexData[0]) ); | |
| 82 | + unsigned short indexData[6] = { 0, 3, 1, 0, 2, 3 }; | |
| 87 | 83 | |
| 88 | 84 | // Create the geometry object |
| 89 | 85 | Geometry texturedQuadGeometry = Geometry::New(); |
| 90 | 86 | texturedQuadGeometry.AddVertexBuffer( texturedQuadVertices ); |
| 91 | - texturedQuadGeometry.SetIndexBuffer( indices ); | |
| 87 | + texturedQuadGeometry.SetIndexBuffer( &indexData[0], sizeof(indexData)/sizeof(indexData[0]) ); | |
| 92 | 88 | |
| 93 | 89 | return texturedQuadGeometry; |
| 94 | 90 | } | ... | ... |