import x11
import egl # local to gamnit
-import display
+intrude import display
+intrude import textures
redef class GamnitDisplay
fun height=(value: Int) do requested_height = value
private var requested_height = 1080
+ redef fun show_cursor do return sdl_display.show_cursor
+
+ redef fun show_cursor=(val) do sdl_display.show_cursor = val
+
# Setup SDL, X11, EGL in order
redef fun setup
do
return x11_display
end
end
+
+redef class TextureAsset
+
+ redef fun load_from_platform
+ do
+ var path = "assets" / path # TODO use app.assets_dir
+ var sdl_tex = new SDLImage.from_file(path)
+
+ if sdl_tex.address_is_null then
+ error = new Error("Failed to load texture at '{path}'")
+ return
+ end
+
+ self.width = sdl_tex.width.to_f
+ self.height = sdl_tex.height.to_f
+ var format = if sdl_tex.amask > 0 then gl_RGBA else gl_RGB
+ var pixels = sdl_tex.pixels
+
+ load_from_pixels(pixels, sdl_tex.width, sdl_tex.height, format)
+ end
+end