subsurface broken

Bug #1179641 reported by tobs12
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyGL3Display
New
Undecided
Unassigned

Bug Description

PygameSurface.subsurface and Image.subsurface are broken:
Here is a fix that works for me:

--- /pygl3display/sprites/image.py 2013-05-10 19:35:29.000000000 +0200
+++ /pygl3display/sprites/image.py 2013-05-12 10:39:50.811758200 +0200
@@ -71,20 +71,19 @@
         rheight = min(dy + rect.height, self.intCoords.height) - dy
         childIntCoords = GL3Rect(rx, ry, rwidth, rheight, rwidth * rheight)

- atlasWidth, atlasHeight = self.atlas.size
- top = childIntCoords.y / atlasHeight
- bottom = (childIntCoords.y + childIntCoords.height) / atlasHeight
- left = childIntCoords.x / atlasWidth
- right = (childIntCoords.x + childIntCoords.width) / atlasWidth
+ size = self.atlas.size
+ top = childIntCoords.y / size
+ bottom = (childIntCoords.y + childIntCoords.height) / size
+ left = childIntCoords.x / size
+ right = (childIntCoords.x + childIntCoords.width) / size

         floatCoords = FloatCoords(
- tl = (left, top),
- tr = (right, top),
- br = (right, bottom),
- bl = (left, bottom)
+ top = top, left = left,
+ width = right - left,
+ height = bottom - top
                       )

- return Image(self.atlas, childIntCoords, floatCoords)
+ return Image(self.atlas, childIntCoords, floatCoords, wrapped=False)

 class GPUImage(Image):
     """A GPUImage is an image which only exists on the GPU, and as such

--- /pygl3display/sprites/pygameimages.py 2013-05-10 19:35:29.000000000 +0200
+++ /pygl3display/sprites/pygameimages.py 2013-05-12 10:22:16.789471600 +0200
@@ -164,7 +165,9 @@

     def subsurface(self, rect):
         # TODO: This will need to convert the Pygame rect to a GL rect
- ret = PygameSurface(None)
+ rect=pygame.Rect(rect)
+ ret = PygameSurface(rect.size)
         ret.surface = self.surface.subsurface(rect)
         ret.parent = self
         hwsubsurface = Image.subsurface(self, rect)

Revision history for this message
tobs12 (hans1215) wrote :

Hello,
since I have fixed it myself, this is not high priority for me.

Revision history for this message
David Griffin (habilain) wrote :

Having reviewed the fix, it would appear that it causes resource fragmentation - an extra box is allocated on the atlas. I'll be creating a proper fix relatively shortly, but it seems a little more involved than the process outlined here.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.