lib/gamnit: intro App integration and Android support
[nit.git] / lib / gamnit / display_android.nit
1 # This file is part of NIT (http://www.nitlanguage.org).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Gamnit display implementation for Android
16 #
17 # Generated APK files require OpenGL ES 2.0.
18 #
19 # This modules uses `android::native_app_glue` and the Android NDK.
20 module display_android is
21 android_manifest """<uses-feature android:glEsVersion="0x00020000"/>"""
22 end
23
24 import ::android
25
26 private import gamnit::egl
27
28 redef class GamnitDisplay
29
30 redef fun setup
31 do
32 var native_display = egl_default_display
33 var native_window = app.native_app_glue.window
34
35 setup_egl_display native_display
36
37 # We need 8 bits per color for selection by color
38 select_egl_config(8, 8, 8, 0, 8, 0, 0)
39
40 var format = egl_config.attribs(egl_display).native_visual_id
41 native_window.set_buffers_geometry(0, 0, format)
42
43 setup_egl_context native_window
44 end
45
46 redef fun close do close_egl
47 end