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
699 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);699 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
700 delete[] indexData;700 delete[] indexData;
701 701
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
703 705
704 } else {706 } else {
705 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);707 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
@@ -767,7 +769,9 @@ void GeometryCache::renderQuad(const glm::vec2& topLeft, const glm::vec2& bottom · 61 unmodified lines
767 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);769 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
768 delete[] indexData;770 delete[] indexData;
769 771
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
771 } else {775 } else {
772 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);776 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
773 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);777 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
833 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);837 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
834 delete[] indexData;838 delete[] indexData;
835 839
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
837 843
838 } else {844 } else {
839 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);845 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
@@ -849,8 +855,20 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 9 unmodified lines
849}855}
850 856
851 857
852void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomRight,858void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottomLeft,
853 const glm::vec2& texCoordTopLeft, const glm::vec2& texCoordBottomRight) {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
854 872
855 Vec3PairVec2Pair key(Vec3Pair(topLeft, bottomRight), Vec2Pair(texCoordTopLeft, texCoordBottomRight));873 Vec3PairVec2Pair key(Vec3Pair(topLeft, bottomRight), Vec2Pair(texCoordTopLeft, texCoordBottomRight));
856 874
@@ -872,11 +890,11 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 15 unmodified lines
872 vertex[v++] = texCoordTopLeft.x;890 vertex[v++] = texCoordTopLeft.x;
873 vertex[v++] = texCoordTopLeft.y;891 vertex[v++] = texCoordTopLeft.y;
874 892
875 vertex[v++] = bottomRight.x;893 vertex[v++] = bottomLeft.x;
876 vertex[v++] = topLeft.y;894 vertex[v++] = bottomLeft.y;
877 vertex[v++] = topLeft.z;895 vertex[v++] = bottomLeft.z;
878 vertex[v++] = texCoordBottomRight.x;896 vertex[v++] = texCoordBottomLeft.x;
879 vertex[v++] = texCoordTopLeft.y;897 vertex[v++] = texCoordBottomLeft.y;
880 898
881 vertex[v++] = bottomRight.x;899 vertex[v++] = bottomRight.x;
882 vertex[v++] = bottomRight.y;900 vertex[v++] = bottomRight.y;
@@ -884,11 +902,11 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 1 unmodified line
884 vertex[v++] = texCoordBottomRight.x;902 vertex[v++] = texCoordBottomRight.x;
885 vertex[v++] = texCoordBottomRight.y;903 vertex[v++] = texCoordBottomRight.y;
886 904
887 vertex[v++] = topLeft.x;905 vertex[v++] = topRight.x;
888 vertex[v++] = bottomRight.y;906 vertex[v++] = topRight.y;
889 vertex[v++] = bottomRight.z;907 vertex[v++] = topRight.z;
890 vertex[v++] = texCoordTopLeft.x;908 vertex[v++] = texCoordTopRight.x;
891 vertex[v++] = texCoordBottomRight.y;909 vertex[v++] = texCoordTopRight.y;
892 910
893 glGenBuffers(1, &vbo.first);911 glGenBuffers(1, &vbo.first);
894 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);912 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
@@ -905,8 +923,10 @@ void GeometryCache::renderQuad(const glm::vec3& topLeft, const glm::vec3& bottom · 10 unmodified lines
905 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);923 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);
906 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);924 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices * NUM_BYTES_PER_INDEX, indexData, GL_STATIC_DRAW);
907 delete[] indexData;925 delete[] indexData;
908 926
909 qDebug() << "new quad + texture VBO made -- _quad3DTextureVBOs.size():" << _quad3DTextureVBOs.size();927 #ifdef WANT_DEBUG
928 qDebug() << " _quad3DTextureVBOs.size():" << _quad3DTextureVBOs.size();
929 #endif
910 } else {930 } else {
911 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);931 glBindBuffer(GL_ARRAY_BUFFER, vbo.first);
912 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo.second);932 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
914 934
915 glEnableClientState(GL_VERTEX_ARRAY);935 glEnableClientState(GL_VERTEX_ARRAY);
916 glEnableClientState(GL_TEXTURE_COORD_ARRAY);936 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);
918 glTexCoordPointer(2, GL_FLOAT, NUM_BYTES_PER_VERTEX, (const void *)(3 * sizeof(float)));938 glTexCoordPointer(2, GL_FLOAT, NUM_BYTES_PER_VERTEX, (const void *)(3 * sizeof(float)));
919 939
920 glDrawRangeElementsEXT(GL_QUADS, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);940 glDrawRangeElementsEXT(GL_QUADS, 0, vertices - 1, indices, GL_UNSIGNED_SHORT, 0);