Load PIL image in scene with retina resolution
@upwart, if you really really want to do it, you can create another Scene with the scene_drawing functions in the draw method, then include that as the scene of a SceneView that you place as a subview of of the main Scene’s view. Then all you need is some funky objc to make the upper Scene’s background transparent (thread in this forum).
Awful, but works.
These definitions at the top:
import objc_util glClearColor = objc_util.c.glClearColor glClearColor.restype = None glClearColor.argtypes = [objc_util.c_float, objc_util.c_float, objc_util.c_float, objc_util.c_float] glClear = objc_util.c.glClear glClear.restype = None glClear.argtypes = [objc_util.c_uint] GL_COLOR_BUFFER_BIT = 0x00004000
This in the main Scene's setup method:
spc = scene.SceneView() spc.scene = OntopScene() spc.background_color = 'transparent' spc.frame = self.view.frame.inset(100,100) self.view.add_subview(spc)
Inset by 100 is so that I can still close the scene with the 'X'...
And your drawing code here:
class OntopScene(scene.Scene): def setup(self): self.view.objc_instance.glkView().setOpaque_(False) def draw(self): glClearColor(0, 0, 0, 0) glClear(GL_COLOR_BUFFER_BIT) scene_drawing.stroke(1,0,0) scene_drawing.rect(-50,-50,100,100)
@upwart so you are combining many PIL images into a single SpriteNode because thousands of spritenodes have a performance penalty?
Are all of the subimages continuously changing? Are these mini plots of some sort, or status icons? In other words is there a lot of repeated content? (Can you post a screenshot?)
There may be some low level ways to get from something like an io surface into a texture. Or, there may be ways to create your ui.Images or scene.Textures such that the PIL image can write directly into the buffer, which minimizes the amount of conversions needed.