Commits

Brendan Howell  committed cc8dcb5

cleaned up rendering workarounds for mac

  • Participants
  • Parent commits d18816a

Comments (0)

Files changed (2)

File drawing_cairo.py

 import numpy
 import math
 import array
+import sys
 
 
 class Drawing:
         self.stroke_width = 0
         self.fill = True
         self.fill_color = (0.5, 0, 0.5, 1)
+        if sys.platform == "darwin":
+            self.machack = True  # check if we are on a mac
+        else:
+            self.machack = False
         
     #set up cairo and pango contexts
     def setSurface(self, sdl_surface):
         self.sdl_surface = sdl_surface
         width = sdl_surface.get_width()
         height = sdl_surface.get_height()
+
+        #TODO: try this on the mac with surface.convert instead
+        # of reversing the array - make sure to check platform here
+        #r,g,b,a = subsurf.get_shifts()
+        #print r,g,b,a
+        #rm,gm,bm,am = subsurf.get_masks()
+        #print rm,gm,bm,am
+        #subsurf.set_shifts((a, r, g, b))
+        #subsurf.set_masks((am, rm, gm, bm))
+
         
         self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
         self.ctx = cairo.Context(self.surface)
 
     def _blitToScreen(self):  
         dest = pygame.surfarray.pixels2d(self.sdl_surface)
-        dest.data[:] = self.surface.get_data()[::-1]
+        if self.machack:
+            dest.data[:] = self.surface.get_data()[::-1]
+        else:
+            dest.data[:] = self.surface.get_data()
         #tmp = pygame.transform.flip(self.sdl_surface, True, True)
         #self.sdl_surface.fill((0,0,0))
         #del dest
         
         if fullscreen:
             flags = pygame.FULLSCREEN
-#        else:
-#            flags = 0
+        else:
+            flags = 0  # disable openGL for now
         
-        self.screen = pygame.display.set_mode((x,y), flags, 32)
+        self.screen = pygame.display.set_mode((x,y), flags, 0)
         pygame.display.set_caption('PyCessing - ' + self.filename, "PyCessing")
         module_location = os.path.dirname(__file__)