Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 4 files). Show all
Unified · Split
| @@ -56,6 +56,12 @@ const int NUM_BYTES_PER_VERTEX = NUM_COORDS_PER_VERTEX * sizeof(GLfloat); · 55 unmodified lines | ||
| 56 | 56 | const int NUM_BYTES_PER_INDEX = sizeof(GLushort); |
| 57 | 57 | |
| 58 | 58 | void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { |
| 59 | + gpu::Batch batch; | |
| 60 | + renderSphere(batch, radius, slices, stacks, color, solid, id); | |
| 61 | + gpu::GLBackend::renderBatch(batch); | |
| 62 | +} | |
| 63 | + | |
| 64 | +void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) { | |
| 59 | 65 | bool registered = (id != UNKNOWN_ID); |
| 60 | 66 | |
| 61 | 67 | Vec2Pair radiusKey(glm::vec2(radius, slices), glm::vec2(stacks, 0)); |
| @@ -279,8 +285,6 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm · 217 unmodified lines | ||
| 279 | 285 | gpu::BufferView normalsView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element); |
| 280 | 286 | gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element); |
| 281 | 287 | |
| 282 | − gpu::Batch batch; | |
| 283 | − | |
| 284 | 288 | batch.setInputFormat(streamFormat); |
| 285 | 289 | batch.setInputBuffer(VERTICES_SLOT, verticesView); |
| 286 | 290 | batch.setInputBuffer(NORMALS_SLOT, normalsView); |
| @@ -293,8 +297,6 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm · 6 unmodified lines | ||
| 293 | 297 | batch.drawIndexed(gpu::LINES, indices); |
| 294 | 298 | } |
| 295 | 299 | |
| 296 | − gpu::GLBackend::renderBatch(batch); | |
| 297 | − | |
| 298 | 300 | glDisableClientState(GL_VERTEX_ARRAY); |
| 299 | 301 | glDisableClientState(GL_COLOR_ARRAY); |
| 300 | 302 | |
| @@ -402,7 +404,14 @@ void GeometryCache::renderCone(float base, float height, int slices, int stacks) · 101 unmodified lines | ||
| 402 | 404 | glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); |
| 403 | 405 | } |
| 404 | 406 | |
| 407 | + | |
| 405 | 408 | void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) { |
| 409 | + gpu::Batch batch; | |
| 410 | + renderGrid(batch, xDivisions, yDivisions, color); | |
| 411 | + gpu::GLBackend::renderBatch(batch); | |
| 412 | +} | |
| 413 | + | |
| 414 | +void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color) { | |
| 406 | 415 | IntPair key(xDivisions, yDivisions); |
| 407 | 416 | Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions), glm::vec3(color.z, color.y, xDivisions)); |
| 408 | 417 | |
| @@ -470,15 +479,11 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& · 61 unmodified lines | ||
| 470 | 479 | gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element); |
| 471 | 480 | gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element); |
| 472 | 481 | |
| 473 | − gpu::Batch batch; | |
| 474 | − | |
| 475 | 482 | batch.setInputFormat(streamFormat); |
| 476 | 483 | batch.setInputBuffer(VERTICES_SLOT, verticesView); |
| 477 | 484 | batch.setInputBuffer(COLOR_SLOT, colorView); |
| 478 | 485 | batch.draw(gpu::LINES, vertices, 0); |
| 479 | 486 | |
| 480 | − gpu::GLBackend::renderBatch(batch); | |
| 481 | − | |
| 482 | 487 | glDisableClientState(GL_VERTEX_ARRAY); |
| 483 | 488 | glDisableClientState(GL_COLOR_ARRAY); |
| 484 | 489 | |
| @@ -486,9 +491,15 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& · 1 unmodified line | ||
| 486 | 491 | |
| 487 | 492 | } |
| 488 | 493 | |
| 494 | +void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { | |
| 495 | + gpu::Batch batch; | |
| 496 | + renderGrid(x, y, width, height, rows, cols, color, id); | |
| 497 | + gpu::GLBackend::renderBatch(batch); | |
| 498 | +} | |
| 499 | + | |
| 489 | 500 | // TODO: properly handle the x,y,w,h changing for an ID |
| 490 | 501 | // TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that?? |
| 491 | −void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { | |
| 502 | +void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) { | |
| 492 | 503 | #ifdef WANT_DEBUG |
| 493 | 504 | qCDebug(renderutils) << "GeometryCache::renderGrid(x["<<x<<"], " |
| 494 | 505 | "y["<<y<<"]," |
| @@ -580,16 +591,12 @@ void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, in · 85 unmodified lines | ||
| 580 | 591 | |
| 581 | 592 | gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element); |
| 582 | 593 | gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element); |
| 583 | − | |
| 584 | − gpu::Batch batch; | |
| 585 | 594 | |
| 586 | 595 | batch.setInputFormat(streamFormat); |
| 587 | 596 | batch.setInputBuffer(VERTICES_SLOT, verticesView); |
| 588 | 597 | batch.setInputBuffer(COLOR_SLOT, colorView); |
| 589 | 598 | batch.draw(gpu::LINES, vertices, 0); |
| 590 | 599 | |
| 591 | − gpu::GLBackend::renderBatch(batch); | |
| 592 | − | |
| 593 | 600 | glDisableClientState(GL_VERTEX_ARRAY); |
| 594 | 601 | glDisableClientState(GL_COLOR_ARRAY); |
| 595 | 602 | |
| @@ -810,6 +817,12 @@ void GeometryCache::renderVertices(gpu::Primitive primitiveType, int id) { · 214 unmodified lines | ||
| 810 | 817 | } |
| 811 | 818 | |
| 812 | 819 | void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { |
| 820 | + gpu::Batch batch; | |
| 821 | + renderSolidCube(batch, size, color); | |
| 822 | + gpu::GLBackend::renderBatch(batch); | |
| 823 | +} | |
| 824 | + | |
| 825 | +void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) { | |
| 813 | 826 | Vec2Pair colorKey(glm::vec2(color.x, color.y), glm::vec2(color.z, color.y)); |
| 814 | 827 | const int FLOATS_PER_VERTEX = 3; |
| 815 | 828 | const int VERTICES_PER_FACE = 4; |
| @@ -915,8 +928,6 @@ void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { · 99 unmodified lines | ||
| 915 | 928 | gpu::BufferView normalsView(verticesBuffer, NORMALS_OFFSET, verticesBuffer->getSize(), VERTEX_STRIDE, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element); |
| 916 | 929 | gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element); |
| 917 | 930 | |
| 918 | − gpu::Batch batch; | |
| 919 | − | |
| 920 | 931 | batch.setInputFormat(streamFormat); |
| 921 | 932 | batch.setInputBuffer(VERTICES_SLOT, verticesView); |
| 922 | 933 | batch.setInputBuffer(NORMALS_SLOT, normalsView); |
| @@ -924,8 +935,6 @@ void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { · 1 unmodified line | ||
| 924 | 935 | batch.setIndexBuffer(gpu::UINT8, _solidCubeIndexBuffer, 0); |
| 925 | 936 | batch.drawIndexed(gpu::TRIANGLES, indices); |
| 926 | 937 | |
| 927 | − gpu::GLBackend::renderBatch(batch); | |
| 928 | − | |
| 929 | 938 | glDisableClientState(GL_VERTEX_ARRAY); |
| 930 | 939 | glDisableClientState(GL_COLOR_ARRAY); |
| 931 | 940 | |
| @@ -934,6 +943,12 @@ void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { · 2 unmodified lines | ||
| 934 | 943 | } |
| 935 | 944 | |
| 936 | 945 | void GeometryCache::renderWireCube(float size, const glm::vec4& color) { |
| 946 | + gpu::Batch batch; | |
| 947 | + renderWireCube(batch, size, color); | |
| 948 | + gpu::GLBackend::renderBatch(batch); | |
| 949 | +} | |
| 950 | + | |
| 951 | +void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) { | |
| 937 | 952 | Vec2Pair colorKey(glm::vec2(color.x, color.y),glm::vec2(color.z, color.y)); |
| 938 | 953 | const int FLOATS_PER_VERTEX = 3; |
| 939 | 954 | const int VERTICES_PER_EDGE = 2; |
| @@ -1003,16 +1018,12 @@ void GeometryCache::renderWireCube(float size, const glm::vec4& color) { · 63 unmodified lines | ||
| 1003 | 1018 | gpu::BufferView verticesView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::POSITION)._element); |
| 1004 | 1019 | gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element); |
| 1005 | 1020 | |
| 1006 | − gpu::Batch batch; | |
| 1007 | − | |
| 1008 | 1021 | batch.setInputFormat(streamFormat); |
| 1009 | 1022 | batch.setInputBuffer(VERTICES_SLOT, verticesView); |
| 1010 | 1023 | batch.setInputBuffer(COLOR_SLOT, colorView); |
| 1011 | 1024 | batch.setIndexBuffer(gpu::UINT8, _wireCubeIndexBuffer, 0); |
| 1012 | 1025 | batch.drawIndexed(gpu::LINES, indices); |
| 1013 | 1026 | |
| 1014 | − gpu::GLBackend::renderBatch(batch); | |
| 1015 | − | |
| 1016 | 1027 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1017 | 1028 | glDisableClientState(GL_COLOR_ARRAY); |
| 1018 | 1029 | |
| @@ -1021,6 +1032,12 @@ void GeometryCache::renderWireCube(float size, const glm::vec4& color) { · 2 unmodified lines | ||
| 1021 | 1032 | } |
| 1022 | 1033 | |
| 1023 | 1034 | void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { |
| 1035 | + gpu::Batch batch; | |
| 1036 | + renderBevelCornersRect(batch, x, y, width, height, bevelDistance, color, id); | |
| 1037 | + gpu::GLBackend::renderBatch(batch); | |
| 1038 | +} | |
| 1039 | + | |
| 1040 | +void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) { | |
| 1024 | 1041 | bool registered = (id != UNKNOWN_ID); |
| 1025 | 1042 | Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance)); |
| 1026 | 1043 | BatchItemDetails& details = registered ? _registeredBevelRects[id] : _bevelRects[key]; |
| @@ -1113,14 +1130,10 @@ void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, · 86 unmodified lines | ||
| 1113 | 1130 | delete[] vertexBuffer; |
| 1114 | 1131 | } |
| 1115 | 1132 | |
| 1116 | − gpu::Batch batch; | |
| 1117 | − | |
| 1118 | 1133 | batch.setInputFormat(details.streamFormat); |
| 1119 | 1134 | batch.setInputStream(0, *details.stream); |
| 1120 | 1135 | batch.draw(gpu::QUADS, 4, 0); |
| 1121 | 1136 | |
| 1122 | − gpu::GLBackend::renderBatch(batch); | |
| 1123 | − | |
| 1124 | 1137 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1125 | 1138 | glDisableClientState(GL_COLOR_ARRAY); |
| 1126 | 1139 | |
| @@ -1128,6 +1141,12 @@ void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, · 1 unmodified line | ||
| 1128 | 1141 | } |
| 1129 | 1142 | |
| 1130 | 1143 | void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { |
| 1144 | + gpu::Batch batch; | |
| 1145 | + renderQuad(batch, minCorner, maxCorner, color, id); | |
| 1146 | + gpu::GLBackend::renderBatch(batch); | |
| 1147 | +} | |
| 1148 | + | |
| 1149 | +void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) { | |
| 1131 | 1150 | bool registered = (id != UNKNOWN_ID); |
| 1132 | 1151 | Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color); |
| 1133 | 1152 | BatchItemDetails& details = registered ? _registeredQuad2D[id] : _quad2D[key]; |
| @@ -1193,14 +1212,10 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 59 unmodified lines | ||
| 1193 | 1212 | details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors); |
| 1194 | 1213 | } |
| 1195 | 1214 | |
| 1196 | − gpu::Batch batch; | |
| 1197 | − | |
| 1198 | 1215 | batch.setInputFormat(details.streamFormat); |
| 1199 | 1216 | batch.setInputStream(0, *details.stream); |
| 1200 | 1217 | batch.draw(gpu::QUADS, 4, 0); |
| 1201 | 1218 | |
| 1202 | − gpu::GLBackend::renderBatch(batch); | |
| 1203 | − | |
| 1204 | 1219 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1205 | 1220 | glDisableClientState(GL_COLOR_ARRAY); |
| 1206 | 1221 | |
| @@ -1210,6 +1225,14 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 3 unmodified lines | ||
| 1210 | 1225 | void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, |
| 1211 | 1226 | const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, |
| 1212 | 1227 | const glm::vec4& color, int id) { |
| 1228 | + gpu::Batch batch; | |
| 1229 | + renderQuad(batch, minCorner, maxCorner, texCoordMinCorner, texCoordMaxCorner, color, id); | |
| 1230 | + gpu::GLBackend::renderBatch(batch); | |
| 1231 | +} | |
| 1232 | + | |
| 1233 | +void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, | |
| 1234 | + const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, | |
| 1235 | + const glm::vec4& color, int id) { | |
| 1213 | 1236 | |
| 1214 | 1237 | bool registered = (id != UNKNOWN_ID); |
| 1215 | 1238 | Vec4PairVec4 key(Vec4Pair(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), |
| @@ -1282,8 +1305,6 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 66 unmodified lines | ||
| 1282 | 1305 | details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors); |
| 1283 | 1306 | } |
| 1284 | 1307 | |
| 1285 | − gpu::Batch batch; | |
| 1286 | − | |
| 1287 | 1308 | // glEnable(GL_TEXTURE_2D); |
| 1288 | 1309 | //glBindTexture(GL_TEXTURE_2D, _currentTextureID); // this is quad specific... |
| 1289 | 1310 | |
| @@ -1291,8 +1312,6 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 1 unmodified line | ||
| 1291 | 1312 | batch.setInputStream(0, *details.stream); |
| 1292 | 1313 | batch.draw(gpu::QUADS, 4, 0); |
| 1293 | 1314 | |
| 1294 | − gpu::GLBackend::renderBatch(batch); | |
| 1295 | − | |
| 1296 | 1315 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1297 | 1316 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
| 1298 | 1317 | glDisableClientState(GL_COLOR_ARRAY); |
| @@ -1303,6 +1322,12 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 4 unmodified lines | ||
| 1303 | 1322 | } |
| 1304 | 1323 | |
| 1305 | 1324 | void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { |
| 1325 | + gpu::Batch batch; | |
| 1326 | + renderQuad(batch, minCorner, maxCorner, color, id); | |
| 1327 | + gpu::GLBackend::renderBatch(batch); | |
| 1328 | +} | |
| 1329 | + | |
| 1330 | +void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) { | |
| 1306 | 1331 | bool registered = (id != UNKNOWN_ID); |
| 1307 | 1332 | Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color); |
| 1308 | 1333 | BatchItemDetails& details = registered ? _registeredQuad3D[id] : _quad3D[key]; |
| @@ -1368,14 +1393,10 @@ void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxC · 59 unmodified lines | ||
| 1368 | 1393 | details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors); |
| 1369 | 1394 | } |
| 1370 | 1395 | |
| 1371 | − gpu::Batch batch; | |
| 1372 | − | |
| 1373 | 1396 | batch.setInputFormat(details.streamFormat); |
| 1374 | 1397 | batch.setInputStream(0, *details.stream); |
| 1375 | 1398 | batch.draw(gpu::QUADS, 4, 0); |
| 1376 | 1399 | |
| 1377 | − gpu::GLBackend::renderBatch(batch); | |
| 1378 | − | |
| 1379 | 1400 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1380 | 1401 | glDisableClientState(GL_COLOR_ARRAY); |
| 1381 | 1402 | |
| @@ -1387,6 +1408,17 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 5 unmodified lines | ||
| 1387 | 1408 | const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, |
| 1388 | 1409 | const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight, |
| 1389 | 1410 | const glm::vec4& color, int id) { |
| 1411 | + gpu::Batch batch; | |
| 1412 | + renderQuad(batch, topLeft, bottomLeft, bottomRight, topRight, texCoordTopLeft, texCoordBottomLeft, | |
| 1413 | + texCoordBottomRight, texCoordTopRight, color, id); | |
| 1414 | + gpu::GLBackend::renderBatch(batch); | |
| 1415 | +} | |
| 1416 | + | |
| 1417 | +void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft, | |
| 1418 | + const glm::vec3& bottomRight, const glm::vec3& topRight, | |
| 1419 | + const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft, | |
| 1420 | + const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight, | |
| 1421 | + const glm::vec4& color, int id) { | |
| 1390 | 1422 | |
| 1391 | 1423 | #ifdef WANT_DEBUG |
| 1392 | 1424 | qCDebug(renderutils) << "renderQuad() vec3 + texture VBO..."; |
| @@ -1470,8 +1502,6 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 77 unmodified lines | ||
| 1470 | 1502 | details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors); |
| 1471 | 1503 | } |
| 1472 | 1504 | |
| 1473 | − gpu::Batch batch; | |
| 1474 | − | |
| 1475 | 1505 | glEnable(GL_TEXTURE_2D); |
| 1476 | 1506 | //glBindTexture(GL_TEXTURE_2D, _currentTextureID); // this is quad specific... |
| 1477 | 1507 | |
| @@ -1479,8 +1509,6 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 1 unmodified line | ||
| 1479 | 1509 | batch.setInputStream(0, *details.stream); |
| 1480 | 1510 | batch.draw(gpu::QUADS, 4, 0); |
| 1481 | 1511 | |
| 1482 | − gpu::GLBackend::renderBatch(batch); | |
| 1483 | − | |
| 1484 | 1512 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1485 | 1513 | glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
| 1486 | 1514 | glDisableClientState(GL_COLOR_ARRAY); |
| @@ -1495,6 +1523,12 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 8 unmodified lines | ||
| 1495 | 1523 | } |
| 1496 | 1524 | |
| 1497 | 1525 | void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { |
| 1526 | + gpu::Batch batch; | |
| 1527 | + renderDashedLine(batch, start, end, color, id); | |
| 1528 | + gpu::GLBackend::renderBatch(batch); | |
| 1529 | +} | |
| 1530 | + | |
| 1531 | +void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) { | |
| 1498 | 1532 | bool registered = (id != UNKNOWN_ID); |
| 1499 | 1533 | Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w))); |
| 1500 | 1534 | BatchItemDetails& details = registered ? _registeredDashedLines[id] : _dashedLines[key]; |
| @@ -1594,14 +1628,10 @@ void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& en · 93 unmodified lines | ||
| 1594 | 1628 | #endif |
| 1595 | 1629 | } |
| 1596 | 1630 | |
| 1597 | − gpu::Batch batch; | |
| 1598 | − | |
| 1599 | 1631 | batch.setInputFormat(details.streamFormat); |
| 1600 | 1632 | batch.setInputStream(0, *details.stream); |
| 1601 | 1633 | batch.draw(gpu::LINES, details.vertices, 0); |
| 1602 | 1634 | |
| 1603 | − gpu::GLBackend::renderBatch(batch); | |
| 1604 | − | |
| 1605 | 1635 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1606 | 1636 | glDisableClientState(GL_COLOR_ARRAY); |
| 1607 | 1637 | |
| @@ -1659,6 +1689,13 @@ void GeometryCache::BatchItemDetails::clear() { · 51 unmodified lines | ||
| 1659 | 1689 | |
| 1660 | 1690 | void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, |
| 1661 | 1691 | const glm::vec4& color1, const glm::vec4& color2, int id) { |
| 1692 | + gpu::Batch batch; | |
| 1693 | + renderLine(batch, p1, p2, color1, color2, id); | |
| 1694 | + gpu::GLBackend::renderBatch(batch); | |
| 1695 | +} | |
| 1696 | + | |
| 1697 | +void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2, | |
| 1698 | + const glm::vec4& color1, const glm::vec4& color2, int id) { | |
| 1662 | 1699 | |
| 1663 | 1700 | bool registered = (id != UNKNOWN_ID); |
| 1664 | 1701 | Vec3Pair key(p1, p2); |
| @@ -1735,21 +1772,23 @@ void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, · 70 unmodified lines | ||
| 1735 | 1772 | #endif |
| 1736 | 1773 | } |
| 1737 | 1774 | |
| 1738 | − gpu::Batch batch; | |
| 1739 | − | |
| 1740 | 1775 | // this is what it takes to render a quad |
| 1741 | 1776 | batch.setInputFormat(details.streamFormat); |
| 1742 | 1777 | batch.setInputStream(0, *details.stream); |
| 1743 | 1778 | batch.draw(gpu::LINES, 2, 0); |
| 1744 | 1779 | |
| 1745 | − gpu::GLBackend::renderBatch(batch); | |
| 1746 | − | |
| 1747 | 1780 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1748 | 1781 | glDisableClientState(GL_COLOR_ARRAY); |
| 1749 | 1782 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 1750 | 1783 | } |
| 1751 | 1784 | |
| 1752 | −void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, | |
| 1785 | +void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color1, const glm::vec4& color2, int id) { | |
| 1786 | + gpu::Batch batch; | |
| 1787 | + renderLine(batch, p1, p2, color1, color2, id); | |
| 1788 | + gpu::GLBackend::renderBatch(batch); | |
| 1789 | +} | |
| 1790 | + | |
| 1791 | +void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2, | |
| 1753 | 1792 | const glm::vec4& color1, const glm::vec4& color2, int id) { |
| 1754 | 1793 | |
| 1755 | 1794 | bool registered = (id != UNKNOWN_ID); |
| @@ -1827,15 +1866,11 @@ void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, · 71 unmodified lines | ||
| 1827 | 1866 | #endif |
| 1828 | 1867 | } |
| 1829 | 1868 | |
| 1830 | − gpu::Batch batch; | |
| 1831 | − | |
| 1832 | 1869 | // this is what it takes to render a quad |
| 1833 | 1870 | batch.setInputFormat(details.streamFormat); |
| 1834 | 1871 | batch.setInputStream(0, *details.stream); |
| 1835 | 1872 | batch.draw(gpu::LINES, 2, 0); |
| 1836 | 1873 | |
| 1837 | − gpu::GLBackend::renderBatch(batch); | |
| 1838 | − | |
| 1839 | 1874 | glDisableClientState(GL_VERTEX_ARRAY); |
| 1840 | 1875 | glDisableClientState(GL_COLOR_ARRAY); |
| 1841 | 1876 | glBindBuffer(GL_ARRAY_BUFFER, 0); |