zxnmbv12312312 / rokon

Automatically exported from code.google.com/p/rokon
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

[PATCH] Polygon retains invalid BufferObject when new vertices are added #151

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a new Polygon with some vertices.
2. Call getBufferObject() (or do something else that calls it, such as using it 
to construct a PolygonSprite()). This creates a BufferObject and caches it in 
"buffer".
3. Add some more vertices to the polygon.
4. Call getBufferObject() (or construct a PolygonSprite() from the polygon).

What is the expected output?

The buffer should reflect the current state of the vertices. It should be 
recalculated when new vertices are added.

What do you see instead?

Once the buffer is first created, it never changes.

What version of Rokon are you using?
2.0.3

On which version of Android are you experiencing this?
2.2

Please provide any additional information below.

Patch to fix this problem:

--- a/src/com/stickycoding/rokon/Polygon.java
+++ b/src/com/stickycoding/rokon/Polygon.java
@@ -140,6 +140,7 @@ public class Polygon {
         */
        public void addVertex(Point location) {
                vertex[vertexCount++] = location;
+               buffer = null; // old buffer is now invalid^M
        }

        /**

Original issue reported on code.google.com by pjleg...@gmail.com on 30 Aug 2010 at 1:56