diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 225: SceneIdeas: Convert all element array handling from unsigned int to unsigned short.

Message ID 20120627222016.16618.20019.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Jesse Barker June 27, 2012, 10:20 p.m. UTC
------------------------------------------------------------
revno: 225
committer: Jesse Barker <jesse.barker@linaro.org>
branch nick: trunk
timestamp: Wed 2012-06-27 15:16:47 -0700
message:
  SceneIdeas: Convert all element array handling from unsigned int to unsigned short.
  OpenGL ES 2.0 only allows GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT for the index
  type, and the use of GL_UNSIGNED_INT, while legal for OpenGL and permitted by
  several OpenGL ES 2.0 implmentations generates an error on stricter ones.
modified:
  src/scene-ideas/a.cc
  src/scene-ideas/characters.h
  src/scene-ideas/d.cc
  src/scene-ideas/e.cc
  src/scene-ideas/i.cc
  src/scene-ideas/lamp.cc
  src/scene-ideas/lamp.h
  src/scene-ideas/logo.cc
  src/scene-ideas/logo.h
  src/scene-ideas/m.cc
  src/scene-ideas/n.cc
  src/scene-ideas/o.cc
  src/scene-ideas/s.cc
  src/scene-ideas/t.cc
  src/scene-ideas/table.cc
  src/scene-ideas/table.h


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'src/scene-ideas/a.cc'
--- src/scene-ideas/a.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/a.cc	2012-06-27 22:16:47 +0000
@@ -170,10 +170,10 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 28, curOffset));
-    curOffset += (28 * sizeof(unsigned int));
+    curOffset += (28 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 17, curOffset));
-    curOffset += (17 * sizeof(unsigned int));
+    curOffset += (17 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 28, curOffset));
-    curOffset += (28 * sizeof(unsigned int));
+    curOffset += (28 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 17, curOffset));
 }

=== modified file 'src/scene-ideas/characters.h'
--- src/scene-ideas/characters.h	2012-05-08 20:53:58 +0000
+++ src/scene-ideas/characters.h	2012-06-27 22:16:47 +0000
@@ -37,7 +37,7 @@ 
     ~PrimitiveState() {}
     void issue() const
     {
-        glDrawElements(type_, count_, GL_UNSIGNED_INT, 
+        glDrawElements(type_, count_, GL_UNSIGNED_SHORT, 
             reinterpret_cast<const GLvoid*>(bufferOffset_));
     }
 private:
@@ -86,7 +86,7 @@ 
         // Now repeat for our index data.
         glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
         glBufferData(GL_ELEMENT_ARRAY_BUFFER, 
-            indexData_.size() * sizeof(unsigned int), &indexData_.front(), 
+            indexData_.size() * sizeof(unsigned short), &indexData_.front(), 
             GL_STATIC_DRAW);
 
         // Unbind our vertex buffer objects so that their state isn't affected
@@ -103,7 +103,7 @@ 
         vertexArray_(0) {}
     unsigned int bufferObjects_[2];
     std::vector<LibMatrix::vec2> vertexData_;
-    std::vector<unsigned int> indexData_;
+    std::vector<unsigned short> indexData_;
     int vertexIndex_;
     unsigned int vertexArray_;
     std::vector<PrimitiveState> primVec_;

=== modified file 'src/scene-ideas/d.cc'
--- src/scene-ideas/d.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/d.cc	2012-06-27 22:16:47 +0000
@@ -137,6 +137,6 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 34, curOffset));
-    curOffset += (34 * sizeof(unsigned int));
+    curOffset += (34 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 34, curOffset));
 }

=== modified file 'src/scene-ideas/e.cc'
--- src/scene-ideas/e.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/e.cc	2012-06-27 22:16:47 +0000
@@ -134,6 +134,6 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 33, curOffset));
-    curOffset += (33 * sizeof(unsigned int));
+    curOffset += (33 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 33, curOffset));
 }

=== modified file 'src/scene-ideas/i.cc'
--- src/scene-ideas/i.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/i.cc	2012-06-27 22:16:47 +0000
@@ -107,10 +107,10 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 20, curOffset));
-    curOffset += (20 * sizeof(unsigned int));
+    curOffset += (20 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 4, curOffset));
-    curOffset += (4 * sizeof(unsigned int));
+    curOffset += (4 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 20, curOffset));
-    curOffset += (20 * sizeof(unsigned int));
+    curOffset += (20 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 4, curOffset));
 }

=== modified file 'src/scene-ideas/lamp.cc'
--- src/scene-ideas/lamp.cc	2012-05-08 20:53:58 +0000
+++ src/scene-ideas/lamp.cc	2012-06-27 22:16:47 +0000
@@ -204,7 +204,7 @@ 
 
     // Now repeat for our index data.
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
-    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int), &indexData_.front(), GL_STATIC_DRAW);
+    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned short), &indexData_.front(), GL_STATIC_DRAW);
 
     // We're ready to go.
     valid_ = true;
@@ -234,10 +234,10 @@ 
     litProgram_[light0PositionName_] = lightPositions[0];
     litProgram_[light1PositionName_] = lightPositions[1];
     litProgram_[light2PositionName_] = lightPositions[2];
-    static const unsigned int sui(sizeof(unsigned int));
+    static const unsigned int sus(sizeof(unsigned short));
     for (unsigned int i = 0; i < 5; i++)
     {
-        glDrawElements(GL_TRIANGLE_STRIP, 26, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid*>(i * 26 * sui));
+        glDrawElements(GL_TRIANGLE_STRIP, 26, GL_UNSIGNED_SHORT, reinterpret_cast<const GLvoid*>(i * 26 * sus));
     }
     glDisableVertexAttribArray(normalIndex);
     glDisableVertexAttribArray(vertexIndex);
@@ -249,7 +249,7 @@ 
     glEnableVertexAttribArray(vertexIndex);
     unlitProgram_[modelviewName_] = mv;
     unlitProgram_[projectionName_] = projection.getCurrent();
-    glDrawElements(GL_TRIANGLE_FAN, 12, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid*>(5 * 26 * sui));
+    glDrawElements(GL_TRIANGLE_FAN, 12, GL_UNSIGNED_SHORT, reinterpret_cast<const GLvoid*>(5 * 26 * sus));
     glDisableVertexAttribArray(vertexIndex);
     unlitProgram_.stop();
 

=== modified file 'src/scene-ideas/lamp.h'
--- src/scene-ideas/lamp.h	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/lamp.h	2012-06-27 22:16:47 +0000
@@ -56,7 +56,7 @@ 
     static const std::string normalAttribName_;
     static const std::string normalMatrixName_;
     std::vector<LibMatrix::vec3> vertexData_;
-    std::vector<unsigned int> indexData_;
+    std::vector<unsigned short> indexData_;
     unsigned int bufferObjects_[2];
     bool valid_;
 };

=== modified file 'src/scene-ideas/logo.cc'
--- src/scene-ideas/logo.cc	2012-05-08 20:53:58 +0000
+++ src/scene-ideas/logo.cc	2012-06-27 22:16:47 +0000
@@ -487,7 +487,7 @@ 
 
     // Now repeat for our index data.
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
-    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int),
+    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned short),
                  &indexData_.front(), GL_STATIC_DRAW);
 
     // Setup our the texture that the shadow program will use...
@@ -560,7 +560,6 @@ 
 void
 SGILogo::drawElbow(void)
 {
-    static const unsigned int sui(sizeof(unsigned int));
     unsigned int startIdx(0);
     unsigned int endIdx(6);
     if (drawStyle_ == LOGO_NORMAL)
@@ -579,8 +578,8 @@ 
 
     for (unsigned int i = startIdx; i < endIdx; i++)
     {
-        unsigned int curOffset(i * 18 * sui);
-        glDrawElements(GL_TRIANGLE_STRIP, 18, GL_UNSIGNED_INT, 
+        unsigned int curOffset(i * 18 * sizeof(unsigned short));
+        glDrawElements(GL_TRIANGLE_STRIP, 18, GL_UNSIGNED_SHORT, 
              reinterpret_cast<const GLvoid*>(curOffset));
     }
 }

=== modified file 'src/scene-ideas/logo.h'
--- src/scene-ideas/logo.h	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/logo.h	2012-06-27 22:16:47 +0000
@@ -71,7 +71,7 @@ 
     std::vector<LibMatrix::vec3> elbowVertices_;
     std::vector<LibMatrix::vec3> elbowNormals_;
     std::vector<LibMatrix::vec3> elbowShadowVertices_;
-    std::vector<unsigned int> indexData_;
+    std::vector<unsigned short> indexData_;
     // A simple map so we know where each section of our data starts within
     // our vertex buffer object.
     struct VertexDataMap

=== modified file 'src/scene-ideas/m.cc'
--- src/scene-ideas/m.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/m.cc	2012-06-27 22:16:47 +0000
@@ -197,14 +197,14 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 13, curOffset));
-    curOffset += (13 * sizeof(unsigned int));
+    curOffset += (13 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 17, curOffset));
-    curOffset += (17 * sizeof(unsigned int));
+    curOffset += (17 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 24, curOffset));
-    curOffset += (24 * sizeof(unsigned int));
+    curOffset += (24 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 13, curOffset));
-    curOffset += (13 * sizeof(unsigned int));
+    curOffset += (13 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 17, curOffset));
-    curOffset += (17 * sizeof(unsigned int));
+    curOffset += (17 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 24, curOffset));
 }

=== modified file 'src/scene-ideas/n.cc'
--- src/scene-ideas/n.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/n.cc	2012-06-27 22:16:47 +0000
@@ -137,10 +137,10 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 11, curOffset));
-    curOffset += (11 * sizeof(unsigned int));
+    curOffset += (11 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 23, curOffset));
-    curOffset += (23 * sizeof(unsigned int));
+    curOffset += (23 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 11, curOffset));
-    curOffset += (11 * sizeof(unsigned int));
+    curOffset += (11 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 23, curOffset));
 }

=== modified file 'src/scene-ideas/o.cc'
--- src/scene-ideas/o.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/o.cc	2012-06-27 22:16:47 +0000
@@ -134,6 +134,6 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 33, curOffset));
-    curOffset += (33 * sizeof(unsigned int));
+    curOffset += (33 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 33, curOffset));
 }

=== modified file 'src/scene-ideas/s.cc'
--- src/scene-ideas/s.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/s.cc	2012-06-27 22:16:47 +0000
@@ -125,6 +125,6 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 30, curOffset));
-    curOffset += (30 * sizeof(unsigned int));
+    curOffset += (30 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 30, curOffset));
 }

=== modified file 'src/scene-ideas/t.cc'
--- src/scene-ideas/t.cc	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/t.cc	2012-06-27 22:16:47 +0000
@@ -134,14 +134,14 @@ 
     // Primitive state so that the draw call can issue the primitives we want.
     unsigned int curOffset(0);
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 18, curOffset));
-    curOffset += (18 * sizeof(unsigned int));
+    curOffset += (18 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 7, curOffset));
-    curOffset += (7 * sizeof(unsigned int));
+    curOffset += (7 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 8, curOffset));
-    curOffset += (8 * sizeof(unsigned int));
+    curOffset += (8 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 18, curOffset));
-    curOffset += (18 * sizeof(unsigned int));
+    curOffset += (18 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 7, curOffset));
-    curOffset += (7 * sizeof(unsigned int));
+    curOffset += (7 * sizeof(unsigned short));
     primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 8, curOffset));
 }

=== modified file 'src/scene-ideas/table.cc'
--- src/scene-ideas/table.cc	2012-05-08 20:53:58 +0000
+++ src/scene-ideas/table.cc	2012-06-27 22:16:47 +0000
@@ -178,7 +178,7 @@ 
 
     // Now repeat for our index data.
     glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
-    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int),
+    glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned short),
                  &indexData_.front(), GL_STATIC_DRAW);
 
     // We're ready to go.
@@ -238,8 +238,8 @@ 
     static const unsigned int twiceRes(2 * (TABLERES_ + 1));
     for (unsigned int i = 0; i < TABLERES_; i++)
     {
-        glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_INT,
-            reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned int)));
+        glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_SHORT,
+            reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned short)));
     }
     glDisableVertexAttribArray(tableVertexIndex_);
     tableProgram_.stop();
@@ -340,8 +340,8 @@ 
     static const unsigned int twiceRes(2 * (TABLERES_ + 1));
     for (unsigned int i = 0; i < TABLERES_; i++)
     {
-        glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_INT,
-            reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned int)));
+        glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_SHORT,
+            reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned short)));
     }
     glDisableVertexAttribArray(underVertexIndex_);
     underProgram_.stop();

=== modified file 'src/scene-ideas/table.h'
--- src/scene-ideas/table.h	2012-04-30 18:37:22 +0000
+++ src/scene-ideas/table.h	2012-06-27 22:16:47 +0000
@@ -83,7 +83,7 @@ 
         unsigned int totalSize;
     } dataMap_;
     unsigned int bufferObjects_[2];
-    std::vector<unsigned int> indexData_;
+    std::vector<unsigned short> indexData_;
     int tableVertexIndex_;
     int paperVertexIndex_;
     int textVertexIndex_;