Commits

Toni Ruža committed 0e97250

Fix for initialising OpenGL textures from wxBitmaps on OSX, just ignores the alpha channel for now.

  • Participants
  • Parent commits dbde943

Comments (0)

Files changed (2)

File glutton/utils.py

         self.name = glGenTextures(1)
         self.bind()
 
-        if bitmap.HasAlpha():
+        # bitmap.HasAlpha() does not work reliably on OSX, it returns True for
+        # an wx.EmptyBitmap that has been drawn to via a MemoryDC
+        if False:#bitmap.HasAlpha():
             kind = GL_RGBA
             data = array.array('B', [0] * bitmap.Width * bitmap.Height * 4)
             bitmap.CopyToBuffer(data, wx.BitmapBufferFormat_RGBA)
             kind, GL_UNSIGNED_BYTE, data.tostring()
         )
 
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)
+        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
         if linear:
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)

File test_sprite.py

 
 
 def generate_bitmap():
-    bitmap = wx.EmptyBitmap(200, 100)
-    dc = wx.MemoryDC()
-    dc.SelectObject(bitmap)
+    bitmap = wx.EmptyBitmap(128, 128)
+    dc = wx.MemoryDC(bitmap)
 
     dc.SetBrush(wx.GREY_BRUSH)
-    dc.DrawRectangle(0, 0, 200, 100)
+    dc.DrawRectangle(0, 0, 128, 128)
     dc.SetPen(wx.WHITE_PEN)
-    dc.DrawLine(0, 0, 199, 99)
-    dc.DrawLine(199, 0, 0, 99)
+    dc.DrawLine(0, 0, 127, 127)
+    dc.DrawLine(127, 0, 0, 127)
 
     dc.SelectObject(wx.NullBitmap)
     return bitmap