Smart pointers fixes
Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 61 files). Show all
Unified · Split
| @@ -79,8 +79,8 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in · 78 unmodified lines | |||
| 79 | qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED VERTICES BUFFER"; | 79 | qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED VERTICES BUFFER"; |
| 80 | #endif | 80 | #endif |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 83 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 84 | if (registered) { | 84 | if (registered) { |
| 85 | _registeredSphereVertices[id] = verticesBuffer; | 85 | _registeredSphereVertices[id] = verticesBuffer; |
| 86 | _lastRegisteredSphereVertices[id] = radiusKey; | 86 | _lastRegisteredSphereVertices[id] = radiusKey; |
| @@ -144,7 +144,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in · 57 unmodified lines | |||
| 144 | #endif | 144 | #endif |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | gpu::BufferPointer indicesBuffer(new gpu::Buffer()); | 147 | auto indicesBuffer = std::make_shared<gpu::Buffer>(); |
| 148 | if (registered) { | 148 | if (registered) { |
| 149 | _registeredSphereIndices[id] = indicesBuffer; | 149 | _registeredSphereIndices[id] = indicesBuffer; |
| 150 | _lastRegisteredSphereIndices[id] = slicesStacksKey; | 150 | _lastRegisteredSphereIndices[id] = slicesStacksKey; |
| @@ -229,8 +229,8 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in · 78 unmodified lines | |||
| 229 | qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED COLORS BUFFER"; | 229 | qCDebug(renderutils) << "renderSphere()... RELEASING REGISTERED COLORS BUFFER"; |
| 230 | #endif | 230 | #endif |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 233 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 234 | if (registered) { | 234 | if (registered) { |
| 235 | _registeredSphereColors[id] = colorBuffer; | 235 | _registeredSphereColors[id] = colorBuffer; |
| 236 | _lastRegisteredSphereColors[id] = colorKey; | 236 | _lastRegisteredSphereColors[id] = colorKey; |
| @@ -278,7 +278,7 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in · 41 unmodified lines | |||
| 278 | static gpu::Stream::FormatPointer streamFormat; | 278 | static gpu::Stream::FormatPointer streamFormat; |
| 279 | static gpu::Element positionElement, normalElement, colorElement; | 279 | static gpu::Element positionElement, normalElement, colorElement; |
| 280 | if (!streamFormat) { | 280 | if (!streamFormat) { |
| 281 | streamFormat.reset(new gpu::Stream::Format()); // 1 for everyone | 281 | streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone |
| 282 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); | 282 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); |
| 283 | streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); | 283 | streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); |
| 284 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); | 284 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); |
| @@ -316,7 +316,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions · 31 unmodified lines | |||
| 316 | 316 | ||
| 317 | int vertices = (xDivisions + 1 + yDivisions + 1) * 2; | 317 | int vertices = (xDivisions + 1 + yDivisions + 1) * 2; |
| 318 | if (!_gridBuffers.contains(key)) { | 318 | if (!_gridBuffers.contains(key)) { |
| 319 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 319 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 320 | 320 | ||
| 321 | GLfloat* vertexData = new GLfloat[vertices * 2]; | 321 | GLfloat* vertexData = new GLfloat[vertices * 2]; |
| 322 | GLfloat* vertex = vertexData; | 322 | GLfloat* vertex = vertexData; |
| @@ -347,7 +347,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions · 24 unmodified lines | |||
| 347 | } | 347 | } |
| 348 | 348 | ||
| 349 | if (!_gridColors.contains(colorKey)) { | 349 | if (!_gridColors.contains(colorKey)) { |
| 350 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 350 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 351 | _gridColors[colorKey] = colorBuffer; | 351 | _gridColors[colorKey] = colorBuffer; |
| 352 | 352 | ||
| 353 | int compactColor = ((int(color.x * 255.0f) & 0xFF)) | | 353 | int compactColor = ((int(color.x * 255.0f) & 0xFF)) | |
| @@ -370,7 +370,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions · 16 unmodified lines | |||
| 370 | 370 | ||
| 371 | const int VERTICES_SLOT = 0; | 371 | const int VERTICES_SLOT = 0; |
| 372 | const int COLOR_SLOT = 1; | 372 | const int COLOR_SLOT = 1; |
| 373 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone | 373 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone |
| 374 | 374 | ||
| 375 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); | 375 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); |
| 376 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); | 376 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); |
| @@ -417,7 +417,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h · 40 unmodified lines | |||
| 417 | #endif | 417 | #endif |
| 418 | } | 418 | } |
| 419 | 419 | ||
| 420 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 420 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 421 | if (registered) { | 421 | if (registered) { |
| 422 | _registeredAlternateGridBuffers[id] = verticesBuffer; | 422 | _registeredAlternateGridBuffers[id] = verticesBuffer; |
| 423 | _lastRegisteredAlternateGridBuffers[id] = key; | 423 | _lastRegisteredAlternateGridBuffers[id] = key; |
| @@ -458,7 +458,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h · 34 unmodified lines | |||
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | if (!_gridColors.contains(colorKey)) { | 460 | if (!_gridColors.contains(colorKey)) { |
| 461 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 461 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 462 | _gridColors[colorKey] = colorBuffer; | 462 | _gridColors[colorKey] = colorBuffer; |
| 463 | 463 | ||
| 464 | int compactColor = ((int(color.x * 255.0f) & 0xFF)) | | 464 | int compactColor = ((int(color.x * 255.0f) & 0xFF)) | |
| @@ -483,7 +483,7 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h · 18 unmodified lines | |||
| 483 | 483 | ||
| 484 | const int VERTICES_SLOT = 0; | 484 | const int VERTICES_SLOT = 0; |
| 485 | const int COLOR_SLOT = 1; | 485 | const int COLOR_SLOT = 1; |
| 486 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); // 1 for everyone | 486 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone |
| 487 | 487 | ||
| 488 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); | 488 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC2, gpu::FLOAT, gpu::XYZ), 0); |
| 489 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); | 489 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); |
| @@ -511,11 +511,11 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, con · 21 unmodified lines | |||
| 511 | details.isCreated = true; | 511 | details.isCreated = true; |
| 512 | details.vertices = points.size(); | 512 | details.vertices = points.size(); |
| 513 | details.vertexSize = FLOATS_PER_VERTEX; | 513 | details.vertexSize = FLOATS_PER_VERTEX; |
| 514 | 514 | ||
| 515 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 515 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 516 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 516 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 517 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 517 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 518 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 518 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 519 | 519 | ||
| 520 | details.verticesBuffer = verticesBuffer; | 520 | details.verticesBuffer = verticesBuffer; |
| 521 | details.colorBuffer = colorBuffer; | 521 | details.colorBuffer = colorBuffer; |
| @@ -572,11 +572,11 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 50 unmodified lines | |||
| 572 | details.isCreated = true; | 572 | details.isCreated = true; |
| 573 | details.vertices = points.size(); | 573 | details.vertices = points.size(); |
| 574 | details.vertexSize = FLOATS_PER_VERTEX; | 574 | details.vertexSize = FLOATS_PER_VERTEX; |
| 575 | 575 | ||
| 576 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 576 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 577 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 577 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 578 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 578 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 579 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 579 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 580 | 580 | ||
| 581 | details.verticesBuffer = verticesBuffer; | 581 | details.verticesBuffer = verticesBuffer; |
| 582 | details.colorBuffer = colorBuffer; | 582 | details.colorBuffer = colorBuffer; |
| @@ -635,11 +635,11 @@ void GeometryCache::updateVertices(int id, const QVector<glm::vec3>& points, con · 52 unmodified lines | |||
| 635 | details.isCreated = true; | 635 | details.isCreated = true; |
| 636 | details.vertices = points.size(); | 636 | details.vertices = points.size(); |
| 637 | details.vertexSize = FLOATS_PER_VERTEX; | 637 | details.vertexSize = FLOATS_PER_VERTEX; |
| 638 | 638 | ||
| 639 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 639 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 640 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 640 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 641 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 641 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 642 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 642 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 643 | 643 | ||
| 644 | details.verticesBuffer = verticesBuffer; | 644 | details.verticesBuffer = verticesBuffer; |
| 645 | details.colorBuffer = colorBuffer; | 645 | details.colorBuffer = colorBuffer; |
| @@ -726,7 +726,7 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve · 80 unmodified lines | |||
| 726 | const int NORMALS_OFFSET = sizeof(GLfloat) * FLOATS_PER_VERTEX; | 726 | const int NORMALS_OFFSET = sizeof(GLfloat) * FLOATS_PER_VERTEX; |
| 727 | 727 | ||
| 728 | if (!_solidCubeVertices.contains(size)) { | 728 | if (!_solidCubeVertices.contains(size)) { |
| 729 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 729 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 730 | _solidCubeVertices[size] = verticesBuffer; | 730 | _solidCubeVertices[size] = verticesBuffer; |
| 731 | 731 | ||
| 732 | GLfloat* vertexData = new GLfloat[vertexPoints * 2]; // vertices and normals | 732 | GLfloat* vertexData = new GLfloat[vertexPoints * 2]; // vertices and normals |
| @@ -777,15 +777,15 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve · 44 unmodified lines | |||
| 777 | 12,13,14, 14,15,12, // left | 777 | 12,13,14, 14,15,12, // left |
| 778 | 16,17,18, 18,19,16, // bottom | 778 | 16,17,18, 18,19,16, // bottom |
| 779 | 20,21,22, 22,23,20 }; // back | 779 | 20,21,22, 22,23,20 }; // back |
| 780 | 780 | ||
| 781 | gpu::BufferPointer indexBuffer(new gpu::Buffer()); | 781 | auto indexBuffer = std::make_shared<gpu::Buffer>(); |
| 782 | _solidCubeIndexBuffer = indexBuffer; | 782 | _solidCubeIndexBuffer = indexBuffer; |
| 783 | 783 | ||
| 784 | _solidCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); | 784 | _solidCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); |
| 785 | } | 785 | } |
| 786 | 786 | ||
| 787 | if (!_solidCubeColors.contains(colorKey)) { | 787 | if (!_solidCubeColors.contains(colorKey)) { |
| 788 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 788 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 789 | _solidCubeColors[colorKey] = colorBuffer; | 789 | _solidCubeColors[colorKey] = colorBuffer; |
| 790 | 790 | ||
| 791 | const int NUM_COLOR_SCALARS_PER_CUBE = 24; | 791 | const int NUM_COLOR_SCALARS_PER_CUBE = 24; |
| @@ -811,7 +811,7 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve · 19 unmodified lines | |||
| 811 | static gpu::Stream::FormatPointer streamFormat; | 811 | static gpu::Stream::FormatPointer streamFormat; |
| 812 | static gpu::Element positionElement, normalElement, colorElement; | 812 | static gpu::Element positionElement, normalElement, colorElement; |
| 813 | if (!streamFormat) { | 813 | if (!streamFormat) { |
| 814 | streamFormat.reset(new gpu::Stream::Format()); // 1 for everyone | 814 | streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone |
| 815 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); | 815 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); |
| 816 | streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); | 816 | streamFormat->setAttribute(gpu::Stream::NORMAL, NORMALS_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); |
| 817 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); | 817 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); |
| @@ -850,7 +850,7 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec · 32 unmodified lines | |||
| 850 | const int indices = (TOP_EDGES + BOTTOM_EDGES + SIDE_EDGES) * VERTICES_PER_EDGE; | 850 | const int indices = (TOP_EDGES + BOTTOM_EDGES + SIDE_EDGES) * VERTICES_PER_EDGE; |
| 851 | 851 | ||
| 852 | if (!_cubeVerticies.contains(size)) { | 852 | if (!_cubeVerticies.contains(size)) { |
| 853 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 853 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 854 | _cubeVerticies[size] = verticesBuffer; | 854 | _cubeVerticies[size] = verticesBuffer; |
| 855 | 855 | ||
| 856 | int vertexPoints = vertices * FLOATS_PER_VERTEX; | 856 | int vertexPoints = vertices * FLOATS_PER_VERTEX; |
| @@ -876,15 +876,15 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec · 19 unmodified lines | |||
| 876 | 4, 5, 5, 6, 6, 7, 7, 4, // (bottom) | 876 | 4, 5, 5, 6, 6, 7, 7, 4, // (bottom) |
| 877 | 0, 4, 1, 5, 2, 6, 3, 7, // (side edges) | 877 | 0, 4, 1, 5, 2, 6, 3, 7, // (side edges) |
| 878 | }; | 878 | }; |
| 879 | 879 | ||
| 880 | gpu::BufferPointer indexBuffer(new gpu::Buffer()); | 880 | auto indexBuffer = std::make_shared<gpu::Buffer>(); |
| 881 | _wireCubeIndexBuffer = indexBuffer; | 881 | _wireCubeIndexBuffer = indexBuffer; |
| 882 | 882 | ||
| 883 | _wireCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); | 883 | _wireCubeIndexBuffer->append(sizeof(cannonicalIndices), (gpu::Byte*) cannonicalIndices); |
| 884 | } | 884 | } |
| 885 | 885 | ||
| 886 | if (!_cubeColors.contains(colorKey)) { | 886 | if (!_cubeColors.contains(colorKey)) { |
| 887 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 887 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 888 | _cubeColors[colorKey] = colorBuffer; | 888 | _cubeColors[colorKey] = colorBuffer; |
| 889 | 889 | ||
| 890 | const int NUM_COLOR_SCALARS_PER_CUBE = 8; | 890 | const int NUM_COLOR_SCALARS_PER_CUBE = 8; |
| @@ -905,7 +905,7 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec · 14 unmodified lines | |||
| 905 | static gpu::Stream::FormatPointer streamFormat; | 905 | static gpu::Stream::FormatPointer streamFormat; |
| 906 | static gpu::Element positionElement, colorElement; | 906 | static gpu::Element positionElement, colorElement; |
| 907 | if (!streamFormat) { | 907 | if (!streamFormat) { |
| 908 | streamFormat.reset(new gpu::Stream::Format()); // 1 for everyone | 908 | streamFormat = std::make_shared<gpu::Stream::Format>(); // 1 for everyone |
| 909 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); | 909 | streamFormat->setAttribute(gpu::Stream::POSITION, VERTICES_SLOT, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); |
| 910 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); | 910 | streamFormat->setAttribute(gpu::Stream::COLOR, COLOR_SLOT, gpu::Element(gpu::VEC4, gpu::UINT8, gpu::RGBA)); |
| 911 | positionElement = streamFormat->getAttributes().at(gpu::Stream::POSITION)._element; | 911 | positionElement = streamFormat->getAttributes().at(gpu::Stream::POSITION)._element; |
| @@ -957,11 +957,11 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int · 45 unmodified lines | |||
| 957 | details.isCreated = true; | 957 | details.isCreated = true; |
| 958 | details.vertices = NUM_VERTICES; | 958 | details.vertices = NUM_VERTICES; |
| 959 | details.vertexSize = FLOATS_PER_VERTEX; | 959 | details.vertexSize = FLOATS_PER_VERTEX; |
| 960 | 960 | ||
| 961 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 961 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 962 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 962 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 963 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 963 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 964 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 964 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 965 | 965 | ||
| 966 | details.verticesBuffer = verticesBuffer; | 966 | details.verticesBuffer = verticesBuffer; |
| 967 | details.colorBuffer = colorBuffer; | 967 | details.colorBuffer = colorBuffer; |
| @@ -1065,11 +1065,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co · 97 unmodified lines | |||
| 1065 | details.isCreated = true; | 1065 | details.isCreated = true; |
| 1066 | details.vertices = vertices; | 1066 | details.vertices = vertices; |
| 1067 | details.vertexSize = FLOATS_PER_VERTEX; | 1067 | details.vertexSize = FLOATS_PER_VERTEX; |
| 1068 | 1068 | ||
| 1069 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 1069 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 1070 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 1070 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 1071 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 1071 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 1072 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 1072 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 1073 | 1073 | ||
| 1074 | details.verticesBuffer = verticesBuffer; | 1074 | details.verticesBuffer = verticesBuffer; |
| 1075 | details.colorBuffer = colorBuffer; | 1075 | details.colorBuffer = colorBuffer; |
| @@ -1171,11 +1171,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co · 95 unmodified lines | |||
| 1171 | details.isCreated = true; | 1171 | details.isCreated = true; |
| 1172 | details.vertices = vertices; | 1172 | details.vertices = vertices; |
| 1173 | details.vertexSize = FLOATS_PER_VERTEX; | 1173 | details.vertexSize = FLOATS_PER_VERTEX; |
| 1174 | 1174 | ||
| 1175 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 1175 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 1176 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 1176 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 1177 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 1177 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 1178 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 1178 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 1179 | 1179 | ||
| 1180 | details.verticesBuffer = verticesBuffer; | 1180 | details.verticesBuffer = verticesBuffer; |
| 1181 | details.colorBuffer = colorBuffer; | 1181 | details.colorBuffer = colorBuffer; |
| @@ -1250,11 +1250,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co · 68 unmodified lines | |||
| 1250 | details.isCreated = true; | 1250 | details.isCreated = true; |
| 1251 | details.vertices = vertices; | 1251 | details.vertices = vertices; |
| 1252 | details.vertexSize = FLOATS_PER_VERTEX; | 1252 | details.vertexSize = FLOATS_PER_VERTEX; |
| 1253 | 1253 | ||
| 1254 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 1254 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 1255 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 1255 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 1256 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 1256 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 1257 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 1257 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 1258 | 1258 | ||
| 1259 | details.verticesBuffer = verticesBuffer; | 1259 | details.verticesBuffer = verticesBuffer; |
| 1260 | details.colorBuffer = colorBuffer; | 1260 | details.colorBuffer = colorBuffer; |
| @@ -1353,11 +1353,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons · 92 unmodified lines | |||
| 1353 | details.isCreated = true; | 1353 | details.isCreated = true; |
| 1354 | details.vertices = vertices; | 1354 | details.vertices = vertices; |
| 1355 | details.vertexSize = FLOATS_PER_VERTEX; // NOTE: this isn't used for BatchItemDetails maybe we can get rid of it | 1355 | details.vertexSize = FLOATS_PER_VERTEX; // NOTE: this isn't used for BatchItemDetails maybe we can get rid of it |
| 1356 | 1356 | ||
| 1357 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 1357 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 1358 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 1358 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 1359 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 1359 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 1360 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 1360 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 1361 | 1361 | ||
| 1362 | details.verticesBuffer = verticesBuffer; | 1362 | details.verticesBuffer = verticesBuffer; |
| 1363 | details.colorBuffer = colorBuffer; | 1363 | details.colorBuffer = colorBuffer; |
| @@ -1440,11 +1440,11 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, · 76 unmodified lines | |||
| 1440 | details.vertices = (segmentCountFloor + 1) * 2; | 1440 | details.vertices = (segmentCountFloor + 1) * 2; |
| 1441 | details.vertexSize = FLOATS_PER_VERTEX; | 1441 | details.vertexSize = FLOATS_PER_VERTEX; |
| 1442 | details.isCreated = true; | 1442 | details.isCreated = true; |
| 1443 | 1443 | ||
| 1444 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 1444 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 1445 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 1445 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 1446 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 1446 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 1447 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 1447 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 1448 | 1448 | ||
| 1449 | details.verticesBuffer = verticesBuffer; | 1449 | details.verticesBuffer = verticesBuffer; |
| 1450 | details.colorBuffer = colorBuffer; | 1450 | details.colorBuffer = colorBuffer; |
| @@ -1605,11 +1605,11 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm · 154 unmodified lines | |||
| 1605 | details.isCreated = true; | 1605 | details.isCreated = true; |
| 1606 | details.vertices = vertices; | 1606 | details.vertices = vertices; |
| 1607 | details.vertexSize = FLOATS_PER_VERTEX; | 1607 | details.vertexSize = FLOATS_PER_VERTEX; |
| 1608 | 1608 | ||
| 1609 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 1609 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 1610 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 1610 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 1611 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 1611 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 1612 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 1612 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 1613 | 1613 | ||
| 1614 | details.verticesBuffer = verticesBuffer; | 1614 | details.verticesBuffer = verticesBuffer; |
| 1615 | details.colorBuffer = colorBuffer; | 1615 | details.colorBuffer = colorBuffer; |
| @@ -1695,11 +1695,11 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm · 79 unmodified lines | |||
| 1695 | details.isCreated = true; | 1695 | details.isCreated = true; |
| 1696 | details.vertices = vertices; | 1696 | details.vertices = vertices; |
| 1697 | details.vertexSize = FLOATS_PER_VERTEX; | 1697 | details.vertexSize = FLOATS_PER_VERTEX; |
| 1698 | 1698 | ||
| 1699 | gpu::BufferPointer verticesBuffer(new gpu::Buffer()); | 1699 | auto verticesBuffer = std::make_shared<gpu::Buffer>(); |
| 1700 | gpu::BufferPointer colorBuffer(new gpu::Buffer()); | 1700 | auto colorBuffer = std::make_shared<gpu::Buffer>(); |
| 1701 | gpu::Stream::FormatPointer streamFormat(new gpu::Stream::Format()); | 1701 | auto streamFormat = std::make_shared<gpu::Stream::Format>(); |
| 1702 | gpu::BufferStreamPointer stream(new gpu::BufferStream()); | 1702 | auto stream = std::make_shared<gpu::BufferStream>(); |
| 1703 | 1703 | ||
| 1704 | details.verticesBuffer = verticesBuffer; | 1704 | details.verticesBuffer = verticesBuffer; |
| 1705 | details.colorBuffer = colorBuffer; | 1705 | details.colorBuffer = colorBuffer; |
| @@ -1756,7 +1756,7 @@ void GeometryCache::useSimpleDrawPipeline(gpu::Batch& batch) { · 50 unmodified lines | |||
| 1756 | auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); | 1756 | auto program = gpu::ShaderPointer(gpu::Shader::createProgram(vs, ps)); |
| 1757 | gpu::Shader::makeProgram((*program)); | 1757 | gpu::Shader::makeProgram((*program)); |
| 1758 | 1758 | ||
| 1759 | auto state = gpu::StatePointer(new gpu::State()); | 1759 | auto state = std::make_shared<gpu::State>(); |
| 1760 | 1760 | ||
| 1761 | // enable decal blend | 1761 | // enable decal blend |
| 1762 | state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA); | 1762 | state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA); |
| @@ -2129,8 +2129,8 @@ void NetworkGeometry::downloadFinished(QNetworkReply* reply) { · 366 unmodified lines | |||
| 2129 | } | 2129 | } |
| 2130 | QVariantHash lods = _mapping.value("lod").toHash(); | 2130 | QVariantHash lods = _mapping.value("lod").toHash(); |
| 2131 | for (QVariantHash::const_iterator it = lods.begin(); it != lods.end(); it++) { | 2131 | for (QVariantHash::const_iterator it = lods.begin(); it != lods.end(); it++) { |
| 2132 | QSharedPointer<NetworkGeometry> geometry(new NetworkGeometry(url.resolved(it.key()), | 2132 | auto geometry = QSharedPointer<NetworkGeometry>::create(url.resolved(it.key()), |
| 2133 | QSharedPointer<NetworkGeometry>(), true, _mapping, _textureBase)); | 2133 | QSharedPointer<NetworkGeometry>(), true, _mapping, _textureBase); |
| 2134 | geometry->setSelf(geometry.staticCast<Resource>()); | 2134 | geometry->setSelf(geometry.staticCast<Resource>()); |
| 2135 | geometry->setLODParent(_lodParent); | 2135 | geometry->setLODParent(_lodParent); |
| 2136 | _lods.insert(it.value().toFloat(), geometry); | 2136 | _lods.insert(it.value().toFloat(), geometry); |
| @@ -2206,7 +2206,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { · 69 unmodified lines | |||
| 2206 | } | 2206 | } |
| 2207 | 2207 | ||
| 2208 | { | 2208 | { |
| 2209 | networkMesh._indexBuffer = gpu::BufferPointer(new gpu::Buffer()); | 2209 | networkMesh._indexBuffer = std::make_shared<gpu::Buffer>(); |
| 2210 | networkMesh._indexBuffer->resize(totalIndices * sizeof(int)); | 2210 | networkMesh._indexBuffer->resize(totalIndices * sizeof(int)); |
| 2211 | int offset = 0; | 2211 | int offset = 0; |
| 2212 | foreach(const FBXMeshPart& part, mesh.parts) { | 2212 | foreach(const FBXMeshPart& part, mesh.parts) { |
| @@ -2220,7 +2220,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { · 7 unmodified lines | |||
| 2220 | } | 2220 | } |
| 2221 | 2221 | ||
| 2222 | { | 2222 | { |
| 2223 | networkMesh._vertexBuffer = gpu::BufferPointer(new gpu::Buffer()); | 2223 | networkMesh._vertexBuffer = std::make_shared<gpu::Buffer>(); |
| 2224 | // if we don't need to do any blending, the positions/normals can be static | 2224 | // if we don't need to do any blending, the positions/normals can be static |
| 2225 | if (mesh.blendshapes.isEmpty()) { | 2225 | if (mesh.blendshapes.isEmpty()) { |
| 2226 | int normalsOffset = mesh.vertices.size() * sizeof(glm::vec3); | 2226 | int normalsOffset = mesh.vertices.size() * sizeof(glm::vec3); |
| @@ -2248,7 +2248,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { · 21 unmodified lines | |||
| 2248 | mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); | 2248 | mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); |
| 2249 | 2249 | ||
| 2250 | // otherwise, at least the cluster indices/weights can be static | 2250 | // otherwise, at least the cluster indices/weights can be static |
| 2251 | networkMesh._vertexStream = gpu::BufferStreamPointer(new gpu::BufferStream()); | 2251 | networkMesh._vertexStream = std::make_shared<gpu::BufferStream>(); |
| 2252 | networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); | 2252 | networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); |
| 2253 | if (mesh.normals.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, normalsOffset, sizeof(glm::vec3)); | 2253 | if (mesh.normals.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, normalsOffset, sizeof(glm::vec3)); |
| 2254 | if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, tangentsOffset, sizeof(glm::vec3)); | 2254 | if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, tangentsOffset, sizeof(glm::vec3)); |
| @@ -2259,7 +2259,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { · 4 unmodified lines | |||
| 2259 | if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); | 2259 | if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); |
| 2260 | 2260 | ||
| 2261 | int channelNum = 0; | 2261 | int channelNum = 0; |
| 2262 | networkMesh._vertexFormat = gpu::Stream::FormatPointer(new gpu::Stream::Format()); | 2262 | networkMesh._vertexFormat = std::make_shared<gpu::Stream::Format>(); |
| 2263 | networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); | 2263 | networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ), 0); |
| 2264 | if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); | 2264 | if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); |
| 2265 | if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); | 2265 | if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); |
| @@ -2290,7 +2290,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { · 24 unmodified lines | |||
| 2290 | networkMesh._vertexBuffer->setSubData(clusterWeightsOffset, | 2290 | networkMesh._vertexBuffer->setSubData(clusterWeightsOffset, |
| 2291 | mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); | 2291 | mesh.clusterWeights.size() * sizeof(glm::vec4), (gpu::Byte*) mesh.clusterWeights.constData()); |
| 2292 | 2292 | ||
| 2293 | networkMesh._vertexStream = gpu::BufferStreamPointer(new gpu::BufferStream()); | 2293 | networkMesh._vertexStream = std::make_shared<gpu::BufferStream>(); |
| 2294 | if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); | 2294 | if (mesh.tangents.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, 0, sizeof(glm::vec3)); |
| 2295 | if (mesh.colors.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, colorsOffset, sizeof(glm::vec3)); | 2295 | if (mesh.colors.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, colorsOffset, sizeof(glm::vec3)); |
| 2296 | if (mesh.texCoords.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, texCoordsOffset, sizeof(glm::vec2)); | 2296 | if (mesh.texCoords.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, texCoordsOffset, sizeof(glm::vec2)); |
| @@ -2298,7 +2298,7 @@ void NetworkGeometry::setGeometry(const FBXGeometry& geometry) { · 1 unmodified line | |||
| 2298 | if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); | 2298 | if (mesh.clusterWeights.size()) networkMesh._vertexStream->addBuffer(networkMesh._vertexBuffer, clusterWeightsOffset, sizeof(glm::vec4)); |
| 2299 | 2299 | ||
| 2300 | int channelNum = 0; | 2300 | int channelNum = 0; |
| 2301 | networkMesh._vertexFormat = gpu::Stream::FormatPointer(new gpu::Stream::Format()); | 2301 | networkMesh._vertexFormat = std::make_shared<gpu::Stream::Format>(); |
| 2302 | networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); | 2302 | networkMesh._vertexFormat->setAttribute(gpu::Stream::POSITION, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); |
| 2303 | if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); | 2303 | if (mesh.normals.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::NORMAL, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); |
| 2304 | if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); | 2304 | if (mesh.tangents.size()) networkMesh._vertexFormat->setAttribute(gpu::Stream::TANGENT, channelNum++, gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); |