History

Restore gl* calls but record them with batch

Atlante45 committed 11 years ago

Commit c2204351 parent 90935d51 file · +76 −83Browse files

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

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+76−83
@@ -59,12 +59,6 @@ void GeometryCache::renderSphere(float radius, int slices, int stacks, const glm · 58 unmodified lines
5959 gpu::Batch batch;
6060 renderSphere(batch, radius, slices, stacks, color, solid, id);
6161 gpu::GLBackend::renderBatch(batch);
62−
63− glDisableClientState(GL_VERTEX_ARRAY);
64− glDisableClientState(GL_COLOR_ARRAY);
65−
66− glBindBuffer(GL_ARRAY_BUFFER, 0);
67− glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
6862 }
6963
7064 void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, int stacks, const glm::vec4& color, bool solid, int id) {
@@ -302,6 +296,12 @@ void GeometryCache::renderSphere(gpu::Batch& batch, float radius, int slices, in · 231 unmodified lines
302296 } else {
303297 batch.drawIndexed(gpu::LINES, indices);
304298 }
299+
300+ batch._glDisableClientState(GL_VERTEX_ARRAY);
301+ batch._glDisableClientState(GL_COLOR_ARRAY);
302+
303+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
304+ batch._glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
305305 }
306306
307307 void GeometryCache::renderCone(float base, float height, int slices, int stacks) {
@@ -409,11 +409,6 @@ void GeometryCache::renderGrid(int xDivisions, int yDivisions, const glm::vec4& · 101 unmodified lines
409409 gpu::Batch batch;
410410 renderGrid(batch, xDivisions, yDivisions, color);
411411 gpu::GLBackend::renderBatch(batch);
412−
413− glDisableClientState(GL_VERTEX_ARRAY);
414− glDisableClientState(GL_COLOR_ARRAY);
415−
416− glBindBuffer(GL_ARRAY_BUFFER, 0);
417412 }
418413
419414 void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions, const glm::vec4& color) {
@@ -488,17 +483,17 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int xDivisions, int yDivisions · 68 unmodified lines
488483 batch.setInputBuffer(VERTICES_SLOT, verticesView);
489484 batch.setInputBuffer(COLOR_SLOT, colorView);
490485 batch.draw(gpu::LINES, vertices, 0);
486+
487+ batch._glDisableClientState(GL_VERTEX_ARRAY);
488+ batch._glDisableClientState(GL_COLOR_ARRAY);
489+
490+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
491491 }
492492
493493 void GeometryCache::renderGrid(int x, int y, int width, int height, int rows, int cols, const glm::vec4& color, int id) {
494494 gpu::Batch batch;
495495 renderGrid(x, y, width, height, rows, cols, color, id);
496496 gpu::GLBackend::renderBatch(batch);
497−
498− glDisableClientState(GL_VERTEX_ARRAY);
499− glDisableClientState(GL_COLOR_ARRAY);
500−
501− glBindBuffer(GL_ARRAY_BUFFER, 0);
502497 }
503498
504499 // TODO: properly handle the x,y,w,h changing for an ID
@@ -600,6 +595,11 @@ void GeometryCache::renderGrid(gpu::Batch& batch, int x, int y, int width, int h · 95 unmodified lines
600595 batch.setInputBuffer(VERTICES_SLOT, verticesView);
601596 batch.setInputBuffer(COLOR_SLOT, colorView);
602597 batch.draw(gpu::LINES, vertices, 0);
598+
599+ batch._glDisableClientState(GL_VERTEX_ARRAY);
600+ batch._glDisableClientState(GL_COLOR_ARRAY);
601+
602+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
603603 }
604604
605605 void GeometryCache::updateVertices(int id, const QVector<glm::vec2>& points, const glm::vec4& color) {
@@ -801,11 +801,6 @@ void GeometryCache::renderVertices(gpu::Primitive primitiveType, int id) { · 195 unmodified lines
801801 gpu::Batch batch;
802802 renderVertices(batch, primitiveType, id);
803803 gpu::GLBackend::renderBatch(batch);
804−
805− glDisableClientState(GL_VERTEX_ARRAY);
806− glDisableClientState(GL_COLOR_ARRAY);
807−
808− glBindBuffer(GL_ARRAY_BUFFER, 0);
809804 }
810805
811806 void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveType, int id) {
@@ -814,6 +809,11 @@ void GeometryCache::renderVertices(gpu::Batch& batch, gpu::Primitive primitiveTy · 2 unmodified lines
814809 batch.setInputFormat(details.streamFormat);
815810 batch.setInputStream(0, *details.stream);
816811 batch.draw(primitiveType, details.vertices, 0);
812+
813+ batch._glDisableClientState(GL_VERTEX_ARRAY);
814+ batch._glDisableClientState(GL_COLOR_ARRAY);
815+
816+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
817817 }
818818 }
819819
@@ -821,12 +821,6 @@ void GeometryCache::renderSolidCube(float size, const glm::vec4& color) { · 1 unmodified line
821821 gpu::Batch batch;
822822 renderSolidCube(batch, size, color);
823823 gpu::GLBackend::renderBatch(batch);
824−
825− glDisableClientState(GL_VERTEX_ARRAY);
826− glDisableClientState(GL_COLOR_ARRAY);
827−
828− glBindBuffer(GL_ARRAY_BUFFER, 0);
829− glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
830824 }
831825
832826 void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::vec4& color) {
@@ -941,18 +935,18 @@ void GeometryCache::renderSolidCube(gpu::Batch& batch, float size, const glm::ve · 108 unmodified lines
941935 batch.setInputBuffer(COLOR_SLOT, colorView);
942936 batch.setIndexBuffer(gpu::UINT8, _solidCubeIndexBuffer, 0);
943937 batch.drawIndexed(gpu::TRIANGLES, indices);
938+
939+ batch._glDisableClientState(GL_VERTEX_ARRAY);
940+ batch._glDisableClientState(GL_COLOR_ARRAY);
941+
942+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
943+ batch._glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
944944 }
945945
946946 void GeometryCache::renderWireCube(float size, const glm::vec4& color) {
947947 gpu::Batch batch;
948948 renderWireCube(batch, size, color);
949949 gpu::GLBackend::renderBatch(batch);
950−
951− glDisableClientState(GL_VERTEX_ARRAY);
952− glDisableClientState(GL_COLOR_ARRAY);
953−
954− glBindBuffer(GL_ARRAY_BUFFER, 0);
955− glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
956950 }
957951
958952 void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec4& color) {
@@ -1030,17 +1024,18 @@ void GeometryCache::renderWireCube(gpu::Batch& batch, float size, const glm::vec · 71 unmodified lines
10301024 batch.setInputBuffer(COLOR_SLOT, colorView);
10311025 batch.setIndexBuffer(gpu::UINT8, _wireCubeIndexBuffer, 0);
10321026 batch.drawIndexed(gpu::LINES, indices);
1027+
1028+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1029+ batch._glDisableClientState(GL_COLOR_ARRAY);
1030+
1031+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
1032+ batch._glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
10331033 }
10341034
10351035 void GeometryCache::renderBevelCornersRect(int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) {
10361036 gpu::Batch batch;
10371037 renderBevelCornersRect(batch, x, y, width, height, bevelDistance, color, id);
10381038 gpu::GLBackend::renderBatch(batch);
1039−
1040− glDisableClientState(GL_VERTEX_ARRAY);
1041− glDisableClientState(GL_COLOR_ARRAY);
1042−
1043− glBindBuffer(GL_ARRAY_BUFFER, 0);
10441039 }
10451040
10461041 void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int width, int height, int bevelDistance, const glm::vec4& color, int id) {
@@ -1139,17 +1134,17 @@ void GeometryCache::renderBevelCornersRect(gpu::Batch& batch, int x, int y, int · 92 unmodified lines
11391134 batch.setInputFormat(details.streamFormat);
11401135 batch.setInputStream(0, *details.stream);
11411136 batch.draw(gpu::QUADS, 4, 0);
1137+
1138+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1139+ batch._glDisableClientState(GL_COLOR_ARRAY);
1140+
1141+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
11421142 }
11431143
11441144 void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {
11451145 gpu::Batch batch;
11461146 renderQuad(batch, minCorner, maxCorner, color, id);
11471147 gpu::GLBackend::renderBatch(batch);
1148−
1149− glDisableClientState(GL_VERTEX_ARRAY);
1150− glDisableClientState(GL_COLOR_ARRAY);
1151−
1152− glBindBuffer(GL_ARRAY_BUFFER, 0);
11531148 }
11541149
11551150 void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner, const glm::vec4& color, int id) {
@@ -1221,6 +1216,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co · 65 unmodified lines
12211216 batch.setInputFormat(details.streamFormat);
12221217 batch.setInputStream(0, *details.stream);
12231218 batch.draw(gpu::QUADS, 4, 0);
1219+
1220+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1221+ batch._glDisableClientState(GL_COLOR_ARRAY);
1222+
1223+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
12241224 }
12251225
12261226 void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxCorner,
@@ -1229,12 +1229,6 @@ void GeometryCache::renderQuad(const glm::vec2& minCorner, const glm::vec2& maxC · 2 unmodified lines
12291229 gpu::Batch batch;
12301230 renderQuad(batch, minCorner, maxCorner, texCoordMinCorner, texCoordMaxCorner, color, id);
12311231 gpu::GLBackend::renderBatch(batch);
1232−
1233− glDisableClientState(GL_VERTEX_ARRAY);
1234− glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1235− glDisableClientState(GL_COLOR_ARRAY);
1236−
1237− glBindBuffer(GL_ARRAY_BUFFER, 0);
12381232 }
12391233
12401234 void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, const glm::vec2& maxCorner,
@@ -1315,17 +1309,18 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec2& minCorner, co · 74 unmodified lines
13151309 batch.setInputFormat(details.streamFormat);
13161310 batch.setInputStream(0, *details.stream);
13171311 batch.draw(gpu::QUADS, 4, 0);
1312+
1313+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1314+ batch._glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1315+ batch._glDisableClientState(GL_COLOR_ARRAY);
1316+
1317+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
13181318 }
13191319
13201320 void GeometryCache::renderQuad(const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
13211321 gpu::Batch batch;
13221322 renderQuad(batch, minCorner, maxCorner, color, id);
13231323 gpu::GLBackend::renderBatch(batch);
1324−
1325− glDisableClientState(GL_VERTEX_ARRAY);
1326− glDisableClientState(GL_COLOR_ARRAY);
1327−
1328− glBindBuffer(GL_ARRAY_BUFFER, 0);
13291324 }
13301325
13311326 void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, const glm::vec3& maxCorner, const glm::vec4& color, int id) {
@@ -1397,6 +1392,11 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& minCorner, co · 65 unmodified lines
13971392 batch.setInputFormat(details.streamFormat);
13981393 batch.setInputStream(0, *details.stream);
13991394 batch.draw(gpu::QUADS, 4, 0);
1395+
1396+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1397+ batch._glDisableClientState(GL_COLOR_ARRAY);
1398+
1399+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
14001400 }
14011401
14021402 void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft,
@@ -1407,16 +1407,7 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 4 unmodified lines
14071407 gpu::Batch batch;
14081408 renderQuad(batch, topLeft, bottomLeft, bottomRight, topRight, texCoordTopLeft, texCoordBottomLeft,
14091409 texCoordBottomRight, texCoordTopRight, color, id);
1410−
1411− glEnable(GL_TEXTURE_2D);
1412−
14131410 gpu::GLBackend::renderBatch(batch);
1414−
1415− glDisableClientState(GL_VERTEX_ARRAY);
1416− glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1417− glDisableClientState(GL_COLOR_ARRAY);
1418−
1419− glBindBuffer(GL_ARRAY_BUFFER, 0);
14201411 }
14211412
14221413 void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, const glm::vec3& bottomLeft,
@@ -1506,29 +1497,24 @@ void GeometryCache::renderQuad(gpu::Batch& batch, const glm::vec3& topLeft, cons · 83 unmodified lines
15061497 details.verticesBuffer->append(sizeof(vertexBuffer), (gpu::Byte*) vertexBuffer);
15071498 details.colorBuffer->append(sizeof(colors), (gpu::Byte*) colors);
15081499 }
1509−
1510− //glBindTexture(GL_TEXTURE_2D, _currentTextureID); // this is quad specific...
1500+
1501+ batch._glEnable(GL_TEXTURE_2D);
15111502
15121503 batch.setInputFormat(details.streamFormat);
15131504 batch.setInputStream(0, *details.stream);
15141505 batch.draw(gpu::QUADS, 4, 0);
15151506
1516− // TODO: The callers of this method (renderMagnifier and renderReticle) assume that we won't disable an unbind
1517− // the texture after rendering. I'm not sure if this is correct in general but it's currently required for the
1518− // oculus overlay to work.
1519− //glBindTexture(GL_TEXTURE_2D, 0);
1520− //glDisable(GL_TEXTURE_2D);
1507+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1508+ batch._glDisableClientState(GL_TEXTURE_COORD_ARRAY);
1509+ batch._glDisableClientState(GL_COLOR_ARRAY);
1510+
1511+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
15211512 }
15221513
15231514 void GeometryCache::renderDashedLine(const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
15241515 gpu::Batch batch;
15251516 renderDashedLine(batch, start, end, color, id);
15261517 gpu::GLBackend::renderBatch(batch);
1527−
1528− glDisableClientState(GL_VERTEX_ARRAY);
1529− glDisableClientState(GL_COLOR_ARRAY);
1530−
1531− glBindBuffer(GL_ARRAY_BUFFER, 0);
15321518 }
15331519
15341520 void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, const glm::vec3& end, const glm::vec4& color, int id) {
@@ -1634,6 +1620,11 @@ void GeometryCache::renderDashedLine(gpu::Batch& batch, const glm::vec3& start, · 99 unmodified lines
16341620 batch.setInputFormat(details.streamFormat);
16351621 batch.setInputStream(0, *details.stream);
16361622 batch.draw(gpu::LINES, details.vertices, 0);
1623+
1624+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1625+ batch._glDisableClientState(GL_COLOR_ARRAY);
1626+
1627+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
16371628 }
16381629
16391630
@@ -1690,10 +1681,6 @@ void GeometryCache::renderLine(const glm::vec3& p1, const glm::vec3& p2, · 50 unmodified lines
16901681 gpu::Batch batch;
16911682 renderLine(batch, p1, p2, color1, color2, id);
16921683 gpu::GLBackend::renderBatch(batch);
1693−
1694− glDisableClientState(GL_VERTEX_ARRAY);
1695− glDisableClientState(GL_COLOR_ARRAY);
1696− glBindBuffer(GL_ARRAY_BUFFER, 0);
16971684 }
16981685
16991686 void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm::vec3& p2,
@@ -1778,16 +1765,17 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec3& p1, const glm · 78 unmodified lines
17781765 batch.setInputFormat(details.streamFormat);
17791766 batch.setInputStream(0, *details.stream);
17801767 batch.draw(gpu::LINES, 2, 0);
1768+
1769+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1770+ batch._glDisableClientState(GL_COLOR_ARRAY);
1771+
1772+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
17811773 }
17821774
17831775 void GeometryCache::renderLine(const glm::vec2& p1, const glm::vec2& p2, const glm::vec4& color1, const glm::vec4& color2, int id) {
17841776 gpu::Batch batch;
17851777 renderLine(batch, p1, p2, color1, color2, id);
17861778 gpu::GLBackend::renderBatch(batch);
1787−
1788− glDisableClientState(GL_VERTEX_ARRAY);
1789− glDisableClientState(GL_COLOR_ARRAY);
1790− glBindBuffer(GL_ARRAY_BUFFER, 0);
17911779 }
17921780
17931781 void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm::vec2& p2,
@@ -1872,6 +1860,11 @@ void GeometryCache::renderLine(gpu::Batch& batch, const glm::vec2& p1, const glm · 78 unmodified lines
18721860 batch.setInputFormat(details.streamFormat);
18731861 batch.setInputStream(0, *details.stream);
18741862 batch.draw(gpu::LINES, 2, 0);
1863+
1864+ batch._glDisableClientState(GL_VERTEX_ARRAY);
1865+ batch._glDisableClientState(GL_COLOR_ARRAY);
1866+
1867+ batch._glBindBuffer(GL_ARRAY_BUFFER, 0);
18751868 }
18761869
18771870