# Partially load this texture from platform-specific features
#
# This method should fill `width`, `height` and `pixels`.
private fun load_from_platform is abstract
lib/gamnit/textures.nit:330,2--333,43
redef fun load_from_platform
do
var path = "assets" / path
var surface = new SDLSurface.load(path.to_cstring)
if surface.address_is_null then
error = new Error("Failed to load texture at '{path}'")
return
end
self.width = surface.w.to_f
self.height = surface.h.to_f
var format = if surface.format.amask > 0u32 then gl_RGBA else gl_RGB
var pixels = surface.pixels
load_from_pixels(pixels, surface.w, surface.h, format)
surface.free
end
lib/gamnit/display_linux.nit:126,2--144,4
redef fun load_from_platform
do
var error = glGetError
assert error == gl_NO_ERROR else print_error error
# Find file
var ns_path = ("assets"/path).to_nsstring
var path_in_bundle = asset_path(ns_path)
if path_in_bundle.address_is_null then
self.error = new Error("Texture at '{path}' not found")
return
end
# Load texture
var glk_texture = glkit_load(path_in_bundle, premultiply_alpha)
if glk_texture.address_is_null then
self.error = new Error("Failed to load texture at '{self.path}'")
return
end
gl_texture = glk_texture.name
width = glk_texture.width.to_f
height = glk_texture.height.to_f
loaded = true
error = glGetError
assert error == gl_NO_ERROR
end
lib/gamnit/display_ios.nit:52,2--79,4
redef fun load_from_platform
do
jni_env.push_local_frame 4
var asset_manager = app.asset_manager
var bmp = load_bitmap(asset_manager, path)
if bmp.is_java_null then
error = new Error("Failed to load texture at '{path}'")
jni_env.pop_local_frame
return
end
var buf = bmp.copy_pixels(unmultiply=not premultiply_alpha)
loaded = true
width = bmp.width.to_f
height = bmp.height.to_f
var pixels = buf.native_array
load_from_pixels(pixels, bmp.width, bmp.height, gl_RGBA)
buf.destroy
bmp.recycle
jni_env.pop_local_frame
end
lib/gamnit/display_android.nit:61,2--84,4