Skip to content

Commit 2b1fae1

Browse files
committed
android: resize buffer
1 parent 3d14a44 commit 2b1fae1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ffi/framebuffer_android.lua

+11-4
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,22 @@ function framebuffer:init()
5454
-- we present this buffer to the outside
5555
self.bb = BB.new(android.screen.width, android.screen.height, BB.TYPE_BBRGB32)
5656
self.invert_bb = BB.new(android.screen.width, android.screen.height, BB.TYPE_BBRGB32)
57-
-- TODO: should we better use these?
58-
-- android.lib.ANativeWindow_getWidth(window)
59-
-- android.lib.ANativeWindow_getHeight(window)
6057
self.bb:fill(BB.COLOR_WHITE)
6158
self:_updateWindow()
62-
6359
framebuffer.parent.init(self)
6460
end
6561

62+
-- resize on rotation or split view.
63+
function framebuffer:resize()
64+
android.screen.width = android.getScreenWidth()
65+
android.screen.height = android.getScreenHeight()
66+
self.bb:free()
67+
self.bb = BB.new(android.screen.width, android.screen.height, BB.TYPE_BBRGB32)
68+
self.invert_bb = BB.new(android.screen.width, android.screen.height, BB.TYPE_BBRGB32)
69+
self.bb:fill(BB.COLOR_WHITE)
70+
self:_updateWindow()
71+
end
72+
6673
function framebuffer:_updateWindow()
6774
if android.app.window == nil then
6875
android.LOGW("cannot blit: no window")

0 commit comments

Comments
 (0)