opengl es - Segmentation fault due to attempt to launch native gles2/egl app on android, without native activity -


sorry english, i'm not native speaker.

i'm trying launch simple gles2/egl app on android (galaxy s4, jelly bean) without native_activity.

i have next main.c:

#include <stdio.h> #include <stdlib.h>  #include <egl/egl.h> #include <gles2/gl2.h>  int main( void ) {   egldisplay dpy;    printf( "hello world.\n" );    dpy = eglgetdisplay( egl_default_display );   printf( "egl dpy: %p.\n", dpy );    return 0; } 

and next android.mk:

local_path := $(call my-dir)  include $(clear_vars)   local_module := hello_world_gr local_src_files := main.c  # have found libglesv2.so , libegl.so libraries , appropriate header files in ndk. local_ldlibs := -l/home/ila/programs/android-ndk-r10e/platforms/android-18/arch-arm/usr/lib -lglesv2 -legl local_c_includes := /home/ila/programs/android-ndk-r10e/platforms/android-18/arch-arm/usr/include  include $(build_executable) 

i have chosen 18-th ndk-supported api level due have 4.3 (jelly bean) android release.

my project's directory looks (before building):

prj: --  jni:     -- main.c     -- android.mk 

so, launch ndk-build (in prj directory) , obtain arm elf executable file in prj/libs/armeabi , in prj/obj/local/armeabi/ name hello_world_gr.

also trying pull out libegl.so , libglesv2.so libraries phone , use them linking.

in both cases, app launched on phone without linker error, app prints hello world , receives segmentation fault in eglgetdisplay delay (in nothing occurred).

if try on desktop ubuntu:

$ gcc -o hello_world_gr main.c -lglesv2 -legl $ ./hello_world_gr hello world. egl dpy: 0x25e7010. 

as can see, fine.

on x11-based target, can obtain eglnativedisplay via, example, xcb_connect(), , pass eglgetdisplay, such function exist android (of course mean c/c++ function)?

you can https://android.googlesource.com/platform/hardware/libhardware/+/master/tests/hwc/ , ensure isn't crazy idea.

i have built , launched example but, again, have received such segmentation fault within eglgetdisplay. (i have built app manually via ndk, no full android build.)

did try this? did success?

i'm not sure why code snippet crashing, wouldn't expect work. not while rest of android framework running.

while think of computers , devices having frame buffer, in practice such thing might inaccessible or not exist @ -- perhaps replaced set of configurable overlays. on android, framebuffers , overlays managed @ lowest level hardware composer (hwc), , @ higher level system graphics compositor (surfaceflinger).

the best place non-app examples frameworks/native/opengl/tests directory. if system compositor running, can ask surface draw on. "angeles" demo provides nice example. uses windowsurface class (in lib directory) top-level display-sized surface surfaceflinger. work while apps running.

if surfaceflinger isn't available, you'll need interact hardware composer directly. tests in hwc directory this. note not work if surfaceflinger running. (and they're old enough might not work @ anymore.)

none of uses public sdk apis, code break if run on older or newer version of android.

more information android graphics architecture, surfaceflinger , hwc, can found here.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -