History

almost completely eliminate immediate mode QUADS

ZappoMan committed 11 years ago

Commit 0790bd71 parent 02a17213 files · +70 −40Browse files

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

Unified · Split

libraries/render-utils/src/GeometryCache.cpp+38−18
@@ -699,7 +699,9 @@ void GeometryCache::renderQuad(const glm::vec2& topLeft, const glm::vec2& bottom · 698 unmodified lines
699699 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
700700 delete[] indexData;
701701
702− qDebug() << "new quad VBO made -- _quad2DVBOs.size():" << _quad2DVBOs.size();
702+ #ifdef WANT_DEBUG
703+ qDebug() << "new quad VBO made -- _quad2DVBOs.size():" << _quad2DVBOs.size();
704+ #endif
703705
704706 } else {
705707 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
@@ -767,7 +769,9 @@ void GeometryCache::renderQuad(const glm::vec2& topLeft, const glm::vec2& bottom · 61 unmodified lines
767769 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
768770 delete[] indexData;
769771
770− qDebug() << "new quad + texture VBO made -- _quad2DTextureVBOs.size():" << _quad2DTextureVBOs.size();
772+ #ifdef WANT_DEBUG
773+ qDebug() << "new quad + texture VBO made -- _quad2DTextureVBOs.size():" << _quad2DTextureVBOs.size();
774+ #endif
771775 } else {
772776 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
773777 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
@@ -833,7 +837,9 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 59 unmodified lines
833837 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
834838 delete[] indexData;
835839
836− qDebug() << "new quad VBO made -- _quad3DVBOs.size():" << _quad3DVBOs.size();
840+ #ifdef WANT_DEBUG
841+ qDebug() << "new quad VBO made -- _quad3DVBOs.size():" << _quad3DVBOs.size();
842+ #endif
837843
838844 } else {
839845 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
@@ -849,8 +855,20 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 9 unmodified lines
849855 }
850856
851857
852−void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomRight,
853− const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomRight) {
858+void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft,
859+ const glm::vec3& bottomRight, const glm::vec3& topRight,
860+ const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomLeft,
861+ const glm::vec2& texCoordBottomRight, const glm::vec2& texCoordTopRight) {
862+
863+ #ifdef WANT_DEBUG
864+ qDebug() << "renderQuad() vec3 + texture VBO...";
865+ qDebug() << " topLeft:" << topLeft;
866+ qDebug() << " bottomLeft:" << bottomLeft;
867+ qDebug() << " bottomRight:" << bottomRight;
868+ qDebug() << " topRight:" << topRight;
869+ qDebug() << " texCoordTopLeft:" << texCoordTopLeft;
870+ qDebug() << " texCoordBottomRight:" << texCoordBottomRight;
871+ #endif //def WANT_DEBUG
854872
855873 Vec3PairVec2Pair key(Vec3Pair(topLeft, bottomRight), Vec2Pair(texCoordTopLeft, texCoordBottomRight));
856874
@@ -872,11 +890,11 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 15 unmodified lines
872890 vertex[v++] = texCoordTopLeft.x;
873891 vertex[v++] = texCoordTopLeft.y;
874892
875− vertex[v++] = bottomRight.x;
876− vertex[v++] = topLeft.y;
877− vertex[v++] = topLeft.z;
878− vertex[v++] = texCoordBottomRight.x;
879− vertex[v++] = texCoordTopLeft.y;
893+ vertex[v++] = bottomLeft.x;
894+ vertex[v++] = bottomLeft.y;
895+ vertex[v++] = bottomLeft.z;
896+ vertex[v++] = texCoordBottomLeft.x;
897+ vertex[v++] = texCoordBottomLeft.y;
880898
881899 vertex[v++] = bottomRight.x;
882900 vertex[v++] = bottomRight.y;
@@ -884,11 +902,11 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 1 unmodified line
884902 vertex[v++] = texCoordBottomRight.x;
885903 vertex[v++] = texCoordBottomRight.y;
886904
887− vertex[v++] = topLeft.x;
888− vertex[v++] = bottomRight.y;
889− vertex[v++] = bottomRight.z;
890− vertex[v++] = texCoordTopLeft.x;
891− vertex[v++] = texCoordBottomRight.y;
905+ vertex[v++] = topRight.x;
906+ vertex[v++] = topRight.y;
907+ vertex[v++] = topRight.z;
908+ vertex[v++] = texCoordTopRight.x;
909+ vertex[v++] = texCoordTopRight.y;
892910
893911 glGenBuffers(1, &vbo.first);
894912 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
@@ -905,8 +923,10 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 10 unmodified lines
905923 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
906924 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
907925 delete[] indexData;
908−
909− qDebug() << "new quad + texture VBO made -- _quad3DTextureVBOs.size():" << _quad3DTextureVBOs.size();
926+
927+ #ifdef WANT_DEBUG
928+ qDebug() << " _quad3DTextureVBOs.size():" << _quad3DTextureVBOs.size();
929+ #endif
910930 } else {
911931 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
912932 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
@@ -914,7 +934,7 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 1 unmodified line
914934
915935 glEnableClientState(GL_VERTEX_ARRAY);
916936 glEnableClientState(GL_TEXTURE_COORD_ARRAY);
917− glVertexPointer(2, GL_FLOAT, NUM_BYTES_PER_VERTEX, 0);
937+ glVertexPointer(3, GL_FLOAT, NUM_BYTES_PER_VERTEX, 0);
918938 glTexCoordPointer(2, GL_FLOAT, NUM_BYTES_PER_VERTEX, (const void *)(3 * sizeof(float)));
919939
920940 glDrawRangeElementsEXT(GL_QUADS, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);