nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ci: compile the manual
[nit.git]
/
lib
/
gamnit
/
display_android.nit
diff --git
a/lib/gamnit/display_android.nit
b/lib/gamnit/display_android.nit
index
6d968f8
..
d198790
100644
(file)
--- a/
lib/gamnit/display_android.nit
+++ b/
lib/gamnit/display_android.nit
@@
-14,11
+14,13
@@
# Gamnit display implementation for Android
#
# Gamnit display implementation for Android
#
-# Generated APK files require OpenGL ES 2.0.
+# Gamnit apps on Android require OpenGL ES 3.0 because, even if it uses only
+# the OpenGL ES 2.0 API, the default shaders have more than 8 vertex attributes.
+# OpenGL ES 3.0 ensures at least 8 vertex attributes, while 2.0 ensures only 4.
#
#
-# This modules uses `android::native_app_glue` and the Android NDK.
+# This module relies on `android::native_app_glue` and the Android NDK.
module display_android is
module display_android is
- android_manifest """<uses-feature android:glEsVersion="0x00020000"/>"""
+ android_manifest """<uses-feature android:glEsVersion="0x00030000" android:required="true" />"""
end
import ::android::game
end
import ::android::game
@@
-37,9
+39,10
@@
redef class GamnitDisplay
setup_egl_display native_display
# We need 8 bits per color for selection by color
setup_egl_display native_display
# We need 8 bits per color for selection by color
- select_egl_config(red_bits, green_bits, blue_bits, 0, 8, 0, 0)
+ select_egl_config(red_bits, green_bits, blue_bits, 0, 8, 0)
var format = egl_config.attribs(egl_display).native_visual_id
var format = egl_config.attribs(egl_display).native_visual_id
+ assert not native_window.address_is_null
native_window.set_buffers_geometry(0, 0, format)
setup_egl_context native_window
native_window.set_buffers_geometry(0, 0, format)
setup_egl_context native_window
@@
-50,12
+53,17
@@
end
redef class TextureAsset
redef class TextureAsset
+ private fun load_bitmap(asset_manager: AssetManager, path: String): NativeBitmap
+ do
+ return asset_manager.bitmap(path)
+ end
+
redef fun load_from_platform
do
jni_env.push_local_frame 4
var asset_manager = app.asset_manager
redef fun load_from_platform
do
jni_env.push_local_frame 4
var asset_manager = app.asset_manager
- var bmp = asset_manager.bitmap(path)
+ 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
if bmp.is_java_null then
error = new Error("Failed to load texture at '{path}'")
jni_env.pop_local_frame
@@
-69,7
+77,14
@@
redef class TextureAsset
var pixels = buf.native_array
load_from_pixels(pixels, bmp.width, bmp.height, gl_RGBA)
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
end
jni_env.pop_local_frame
end
end
+
+redef class Pointer
+ # Disable out premultiply as we use only the one from Android
+ redef fun premultiply_alpha(width, height) do end
+end