History

Update GeometryCache to accept gpu::Batch

Ryan Huffman committed 11 years ago

Commit 5abd4bb1 parent 3471c0a4 files · +170 −56Browse files

Showing the changes to libraries/render-utils/src/GeometryCache.cpp (1 of 4 files). Show all

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+89−54
@@ -56,6 +56,12 @@ const int NUM_BYTES_PER_VERTEX = NUM_COORDS_PER_VERTEX * sizeof(GLfloat); · 55 unmodified lines
56const int NUM_BYTES_PER_INDEX = sizeof(GLushort);56const int NUM_BYTES_PER_INDEX = sizeof(GLushort);
57 57
58void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) {58void 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
64void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) {
59 bool registered = (id != UNKNOWN_ID);65 bool registered = (id != UNKNOWN_ID);
60 66
61 Vec2Pair radiusKey(glm::vec2(radius, slices), glm::vec2(stacks, 0));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 gpu::BufferView normalsView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element);285 gpu::BufferView normalsView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element);
280 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);286 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
281 287
282 gpu::Batch batch;
283
284 batch.setInputFormat(streamFormat);288 batch.setInputFormat(streamFormat);
285 batch.setInputBuffer(VERTICES_SLOT, verticesView);289 batch.setInputBuffer(VERTICES_SLOT, verticesView);
286 batch.setInputBuffer(NORMALS_SLOT, normalsView);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 batch.drawIndexed(gpu::LINES, indices);297 batch.drawIndexed(gpu::LINES, indices);
294 }298 }
295 299
296 gpu::GLBackend::renderBatch(batch);
297
298 glDisableClientState(GL_VERTEX_ARRAY);300 glDisableClientState(GL_VERTEX_ARRAY);
299 glDisableClientState(GL_COLOR_ARRAY);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 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);404 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
403}405}
404 406
407
405void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& color) {408void 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
414void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color) {
406 IntPair key(xDivisions, yDivisions);415 IntPair key(xDivisions, yDivisions);
407 Vec3Pair colorKey(glm::vec3(color.x, color.y, yDivisions), glm::vec3(color.z, color.y, xDivisions));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 gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);479 gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);
471 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);480 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
472 481
473 gpu::Batch batch;
474
475 batch.setInputFormat(streamFormat);482 batch.setInputFormat(streamFormat);
476 batch.setInputBuffer(VERTICES_SLOT, verticesView);483 batch.setInputBuffer(VERTICES_SLOT, verticesView);
477 batch.setInputBuffer(COLOR_SLOT, colorView);484 batch.setInputBuffer(COLOR_SLOT, colorView);
478 batch.draw(gpu::LINES, vertices, 0);485 batch.draw(gpu::LINES, vertices, 0);
479 486
480 gpu::GLBackend::renderBatch(batch);
481
482 glDisableClientState(GL_VERTEX_ARRAY);487 glDisableClientState(GL_VERTEX_ARRAY);
483 glDisableClientState(GL_COLOR_ARRAY);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
494void 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// TODO: properly handle the x,y,w,h changing for an ID500// TODO: properly handle the x,y,w,h changing for an ID
490// TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that??501// TODO: why do we seem to create extra BatchItemDetails when we resize the window?? what's that??
491void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) {502void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) {
492 #ifdef WANT_DEBUG503 #ifdef WANT_DEBUG
493 qCDebug(renderutils) << "GeometryCache::renderGrid(x["<<x<<"], "504 qCDebug(renderutils) << "GeometryCache::renderGrid(x["<<x<<"], "
494 "y["<<y<<"],"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 gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);592 gpu::BufferView verticesView(verticesBuffer, 0, verticesBuffer->getSize(), streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);
582 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);593 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
583
584 gpu::Batch batch;
585 594
586 batch.setInputFormat(streamFormat);595 batch.setInputFormat(streamFormat);
587 batch.setInputBuffer(VERTICES_SLOT, verticesView);596 batch.setInputBuffer(VERTICES_SLOT, verticesView);
588 batch.setInputBuffer(COLOR_SLOT, colorView);597 batch.setInputBuffer(COLOR_SLOT, colorView);
589 batch.draw(gpu::LINES, vertices, 0);598 batch.draw(gpu::LINES, vertices, 0);
590 599
591 gpu::GLBackend::renderBatch(batch);
592
593 glDisableClientState(GL_VERTEX_ARRAY);600 glDisableClientState(GL_VERTEX_ARRAY);
594 glDisableClientState(GL_COLOR_ARRAY);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
812void GeometryCache::renderSolidCube(float size, const glm::vec4& color) {819void GeometryCache::renderSolidCube(float size, const glm::vec4& color) {
820 gpu::Batch batch;
821 renderSolidCube(batch, size, color);
822 gpu::GLBackend::renderBatch(batch);
823}
824
825void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) {
813 Vec2Pair colorKey(glm::vec2(color.x, color.y), glm::vec2(color.z, color.y));826 Vec2Pair colorKey(glm::vec2(color.x, color.y), glm::vec2(color.z, color.y));
814 const int FLOATS_PER_VERTEX = 3;827 const int FLOATS_PER_VERTEX = 3;
815 const int VERTICES_PER_FACE = 4;828 const int VERTICES_PER_FACE = 4;
@@ -915,8 +928,6 @@ void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { · 99 unmodified lines
915 gpu::BufferView normalsView(verticesBuffer, NORMALS_OFFSET, verticesBuffer->getSize(), VERTEX_STRIDE, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element);928 gpu::BufferView normalsView(verticesBuffer, NORMALS_OFFSET, verticesBuffer->getSize(), VERTEX_STRIDE, streamFormat->getAttributes().at(gpu::Stream::NORMAL)._element);
916 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);929 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
917 930
918 gpu::Batch batch;
919
920 batch.setInputFormat(streamFormat);931 batch.setInputFormat(streamFormat);
921 batch.setInputBuffer(VERTICES_SLOT, verticesView);932 batch.setInputBuffer(VERTICES_SLOT, verticesView);
922 batch.setInputBuffer(NORMALS_SLOT, normalsView);933 batch.setInputBuffer(NORMALS_SLOT, normalsView);
@@ -924,8 +935,6 @@ void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { · 1 unmodified line
924 batch.setIndexBuffer(gpu::UINT8, _solidCubeIndexBuffer, 0);935 batch.setIndexBuffer(gpu::UINT8, _solidCubeIndexBuffer, 0);
925 batch.drawIndexed(gpu::TRIANGLES, indices);936 batch.drawIndexed(gpu::TRIANGLES, indices);
926 937
927 gpu::GLBackend::renderBatch(batch);
928
929 glDisableClientState(GL_VERTEX_ARRAY);938 glDisableClientState(GL_VERTEX_ARRAY);
930 glDisableClientState(GL_COLOR_ARRAY);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
936void GeometryCache::renderWireCube(float size, const glm::vec4& color) {945void GeometryCache::renderWireCube(float size, const glm::vec4& color) {
946 gpu::Batch batch;
947 renderWireCube(batch, size, color);
948 gpu::GLBackend::renderBatch(batch);
949}
950
951void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) {
937 Vec2Pair colorKey(glm::vec2(color.x, color.y),glm::vec2(color.z, color.y));952 Vec2Pair colorKey(glm::vec2(color.x, color.y),glm::vec2(color.z, color.y));
938 const int FLOATS_PER_VERTEX = 3;953 const int FLOATS_PER_VERTEX = 3;
939 const int VERTICES_PER_EDGE = 2;954 const int VERTICES_PER_EDGE = 2;
@@ -1003,16 +1018,12 @@ void GeometryCache::renderWireCube(float size, const glm::vec4& color) { · 63 unmodified lines
1003 gpu::BufferView verticesView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);1018 gpu::BufferView verticesView(verticesBuffer, streamFormat->getAttributes().at(gpu::Stream::POSITION)._element);
1004 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);1019 gpu::BufferView colorView(colorBuffer, streamFormat->getAttributes().at(gpu::Stream::COLOR)._element);
1005 1020
1006 gpu::Batch batch;
1007
1008 batch.setInputFormat(streamFormat);1021 batch.setInputFormat(streamFormat);
1009 batch.setInputBuffer(VERTICES_SLOT, verticesView);1022 batch.setInputBuffer(VERTICES_SLOT, verticesView);
1010 batch.setInputBuffer(COLOR_SLOT, colorView);1023 batch.setInputBuffer(COLOR_SLOT, colorView);
1011 batch.setIndexBuffer(gpu::UINT8, _wireCubeIndexBuffer, 0);1024 batch.setIndexBuffer(gpu::UINT8, _wireCubeIndexBuffer, 0);
1012 batch.drawIndexed(gpu::LINES, indices);1025 batch.drawIndexed(gpu::LINES, indices);
1013 1026
1014 gpu::GLBackend::renderBatch(batch);
1015
1016 glDisableClientState(GL_VERTEX_ARRAY);1027 glDisableClientState(GL_VERTEX_ARRAY);
1017 glDisableClientState(GL_COLOR_ARRAY);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
1023void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) {1034void 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
1040void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) {
1024 bool registered = (id != UNKNOWN_ID);1041 bool registered = (id != UNKNOWN_ID);
1025 Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance));1042 Vec3Pair key(glm::vec3(x, y, 0.0f), glm::vec3(width, height, bevelDistance));
1026 BatchItemDetails& details = registered ? _registeredBevelRects[id] : _bevelRects[key];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 delete[] vertexBuffer;1130 delete[] vertexBuffer;
1114 }1131 }
1115 1132
1116 gpu::Batch batch;
1117
1118 batch.setInputFormat(details.streamFormat);1133 batch.setInputFormat(details.streamFormat);
1119 batch.setInputStream(0, *details.stream);1134 batch.setInputStream(0, *details.stream);
1120 batch.draw(gpu::QUADS, 4, 0);1135 batch.draw(gpu::QUADS, 4, 0);
1121 1136
1122 gpu::GLBackend::renderBatch(batch);
1123
1124 glDisableClientState(GL_VERTEX_ARRAY);1137 glDisableClientState(GL_VERTEX_ARRAY);
1125 glDisableClientState(GL_COLOR_ARRAY);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
1130void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {1143void 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
1149void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {
1131 bool registered = (id != UNKNOWN_ID);1150 bool registered = (id != UNKNOWN_ID);
1132 Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color);1151 Vec4Pair key(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y), color);
1133 BatchItemDetails& details = registered ? _registeredQuad2D[id] : _quad2D[key];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 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);1212 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
1194 }1213 }
1195 1214
1196 gpu::Batch batch;
1197
1198 batch.setInputFormat(details.streamFormat);1215 batch.setInputFormat(details.streamFormat);
1199 batch.setInputStream(0, *details.stream);1216 batch.setInputStream(0, *details.stream);
1200 batch.draw(gpu::QUADS, 4, 0);1217 batch.draw(gpu::QUADS, 4, 0);
1201 1218
1202 gpu::GLBackend::renderBatch(batch);
1203
1204 glDisableClientState(GL_VERTEX_ARRAY);1219 glDisableClientState(GL_VERTEX_ARRAY);
1205 glDisableClientState(GL_COLOR_ARRAY);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
1210void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner,1225void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner,
1211 const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner, 1226 const glm::vec2& texCoordMinCorner, const glm::vec2& texCoordMaxCorner,
1212 const glm::vec4& color, int id) {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
1233void 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 bool registered = (id != UNKNOWN_ID);1237 bool registered = (id != UNKNOWN_ID);
1215 Vec4PairVec4 key(Vec4Pair(glm::vec4(minCorner.x, minCorner.y, maxCorner.x, maxCorner.y),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 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);1305 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
1283 }1306 }
1284 1307
1285 gpu::Batch batch;
1286
1287// glEnable(GL_TEXTURE_2D);1308// glEnable(GL_TEXTURE_2D);
1288 //glBindTexture(GL_TEXTURE_2D, _currentTextureID); // this is quad specific...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 batch.setInputStream(0, *details.stream);1312 batch.setInputStream(0, *details.stream);
1292 batch.draw(gpu::QUADS, 4, 0);1313 batch.draw(gpu::QUADS, 4, 0);
1293 1314
1294 gpu::GLBackend::renderBatch(batch);
1295
1296 glDisableClientState(GL_VERTEX_ARRAY);1315 glDisableClientState(GL_VERTEX_ARRAY);
1297 glDisableClientState(GL_TEXTURE_COORD_ARRAY);1316 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1298 glDisableClientState(GL_COLOR_ARRAY);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
1305void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {1324void 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
1330void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
1306 bool registered = (id != UNKNOWN_ID);1331 bool registered = (id != UNKNOWN_ID);
1307 Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color);1332 Vec3PairVec4 key(Vec3Pair(minCorner, maxCorner), color);
1308 BatchItemDetails& details = registered ? _registeredQuad3D[id] : _quad3D[key];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 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);1393 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
1369 }1394 }
1370 1395
1371 gpu::Batch batch;
1372
1373 batch.setInputFormat(details.streamFormat);1396 batch.setInputFormat(details.streamFormat);
1374 batch.setInputStream(0, *details.stream);1397 batch.setInputStream(0, *details.stream);
1375 batch.draw(gpu::QUADS, 4, 0);1398 batch.draw(gpu::QUADS, 4, 0);
1376 1399
1377 gpu::GLBackend::renderBatch(batch);
1378
1379 glDisableClientState(GL_VERTEX_ARRAY);1400 glDisableClientState(GL_VERTEX_ARRAY);
1380 glDisableClientState(GL_COLOR_ARRAY);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 const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,1408 const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,
1388 const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight, 1409 const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight,
1389 const glm::vec4& color, int id) {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
1417void 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 #ifdef WANT_DEBUG1423 #ifdef WANT_DEBUG
1392 qCDebug(renderutils) << "renderQuad() vec3 + texture VBO...";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 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);1502 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
1471 }1503 }
1472 1504
1473 gpu::Batch batch;
1474
1475 glEnable(GL_TEXTURE_2D);1505 glEnable(GL_TEXTURE_2D);
1476 //glBindTexture(GL_TEXTURE_2D, _currentTextureID); // this is quad specific...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 batch.setInputStream(0, *details.stream);1509 batch.setInputStream(0, *details.stream);
1480 batch.draw(gpu::QUADS, 4, 0);1510 batch.draw(gpu::QUADS, 4, 0);
1481 1511
1482 gpu::GLBackend::renderBatch(batch);
1483
1484 glDisableClientState(GL_VERTEX_ARRAY);1512 glDisableClientState(GL_VERTEX_ARRAY);
1485 glDisableClientState(GL_TEXTURE_COORD_ARRAY);1513 glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1486 glDisableClientState(GL_COLOR_ARRAY);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
1497void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {1525void 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
1531void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
1498 bool registered = (id != UNKNOWN_ID);1532 bool registered = (id != UNKNOWN_ID);
1499 Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w)));1533 Vec3PairVec2Pair key(Vec3Pair(start, end), Vec2Pair(glm::vec2(color.x, color.y), glm::vec2(color.z, color.w)));
1500 BatchItemDetails& details = registered ? _registeredDashedLines[id] : _dashedLines[key];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 #endif1628 #endif
1595 }1629 }
1596 1630
1597 gpu::Batch batch;
1598
1599 batch.setInputFormat(details.streamFormat);1631 batch.setInputFormat(details.streamFormat);
1600 batch.setInputStream(0, *details.stream);1632 batch.setInputStream(0, *details.stream);
1601 batch.draw(gpu::LINES, details.vertices, 0);1633 batch.draw(gpu::LINES, details.vertices, 0);
1602 1634
1603 gpu::GLBackend::renderBatch(batch);
1604
1605 glDisableClientState(GL_VERTEX_ARRAY);1635 glDisableClientState(GL_VERTEX_ARRAY);
1606 glDisableClientState(GL_COLOR_ARRAY);1636 glDisableClientState(GL_COLOR_ARRAY);
1607 1637
@@ -1659,6 +1689,13 @@ void GeometryCache::BatchItemDetails::clear() { · 51 unmodified lines
1659 1689
1660void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, 1690void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2,
1661 const glm::vec4& color1, const glm::vec4& color2, int id) {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
1697void 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 bool registered = (id != UNKNOWN_ID);1700 bool registered = (id != UNKNOWN_ID);
1664 Vec3Pair key(p1, p2);1701 Vec3Pair key(p1, p2);
@@ -1735,21 +1772,23 @@ void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, · 70 unmodified lines
1735 #endif1772 #endif
1736 }1773 }
1737 1774
1738 gpu::Batch batch;
1739
1740 // this is what it takes to render a quad1775 // this is what it takes to render a quad
1741 batch.setInputFormat(details.streamFormat);1776 batch.setInputFormat(details.streamFormat);
1742 batch.setInputStream(0, *details.stream);1777 batch.setInputStream(0, *details.stream);
1743 batch.draw(gpu::LINES, 2, 0);1778 batch.draw(gpu::LINES, 2, 0);
1744 1779
1745 gpu::GLBackend::renderBatch(batch);
1746
1747 glDisableClientState(GL_VERTEX_ARRAY);1780 glDisableClientState(GL_VERTEX_ARRAY);
1748 glDisableClientState(GL_COLOR_ARRAY);1781 glDisableClientState(GL_COLOR_ARRAY);
1749 glBindBuffer(GL_ARRAY_BUFFER, 0);1782 glBindBuffer(GL_ARRAY_BUFFER, 0);
1750}1783}
1751 1784
1752void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, 1785void 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
1791void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2,
1753 const glm::vec4& color1, const glm::vec4& color2, int id) {1792 const glm::vec4& color1, const glm::vec4& color2, int id) {
1754 1793
1755 bool registered = (id != UNKNOWN_ID);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 #endif1866 #endif
1828 }1867 }
1829 1868
1830 gpu::Batch batch;
1831
1832 // this is what it takes to render a quad1869 // this is what it takes to render a quad
1833 batch.setInputFormat(details.streamFormat);1870 batch.setInputFormat(details.streamFormat);
1834 batch.setInputStream(0, *details.stream);1871 batch.setInputStream(0, *details.stream);
1835 batch.draw(gpu::LINES, 2, 0);1872 batch.draw(gpu::LINES, 2, 0);
1836 1873
1837 gpu::GLBackend::renderBatch(batch);
1838
1839 glDisableClientState(GL_VERTEX_ARRAY);1874 glDisableClientState(GL_VERTEX_ARRAY);
1840 glDisableClientState(GL_COLOR_ARRAY);1875 glDisableClientState(GL_COLOR_ARRAY);
1841 glBindBuffer(GL_ARRAY_BUFFER, 0);1876 glBindBuffer(GL_ARRAY_BUFFER, 0);