Issue
I'm trying to get an android native activity (fully ndk) to run openGL code.. I've looked around a lot, and spent quite a bit of time on IRC. All roads lead me to naught.
In my app_gradle I've got the following lines
ldFlags.add("-lGLESv2")
ldFlags.add("-lGLESv1_CM")
ldLibs.addAll(["log", "android", "EGL", "GLESv1_CM", "GLESv2"])
I believe that should link the correct libs (Might be overkill)
In my code (main.c) I've got this
#include <EGL/egl.h>
#include <GLES/gl.h>
#include <GLES2/gl2.h>
GLuint loadGLProgram() {
LOGI("GETTING HERE 1");
GLuint program = glCreateProgram();
LOGI("GETTING HERE 2");
....
return program;
}
When I run this code.
...native-activity: GETTING HERE 1
...A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 2965 (native_activity)
I'm wondering if anyone has seen this, or if anyone has ever found/created a simple openGL example that is truly native.
Here's a more detailed log. Still digging.
03-29 22:13:55.030 1013-1013/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-29 22:13:55.030 1013-1013/? A/DEBUG: Build fingerprint: 'Android/sdk_phone_x86_64/generic_x86_64:6.0/MASTER/2524533:userdebug/test-keys'
03-29 22:13:55.030 1013-1013/? A/DEBUG: Revision: '0'
03-29 22:13:55.030 1013-1013/? A/DEBUG: ABI: 'x86'
03-29 22:13:55.030 1013-1013/? A/DEBUG: pid: 2109, tid: 2124, name: com.Little.Aisy >>> com.Little.Aisy <<<
03-29 22:13:55.030 1013-1013/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
03-29 22:13:55.040 1013-1013/? A/DEBUG: eax f69d9ec0 ebx eb7b8d58 ecx e7ecd12c edx e7ecd12c
03-29 22:13:55.040 1013-1013/? A/DEBUG: esi e4b63930 edi e4b63970
03-29 22:13:55.040 1013-1013/? A/DEBUG: xcs 00000023 xds 0000002b xes 0000002b xfs 00000007 xss 0000002b
03-29 22:13:55.040 1013-1013/? A/DEBUG: eip 00000000 ebp e4b63748 esp e4b636ec flags 00210292
03-29 22:13:55.040 1013-1013/? A/DEBUG: backtrace:
03-29 22:13:55.050 1013-1013/? A/DEBUG: #00 pc 00000000 <unknown>
03-29 22:13:55.050 1013-1013/? A/DEBUG: #01 pc 00002a66 /data/app/com.Little.Aisy-2/lib/x86/libnative-activity.so
03-29 22:13:55.050 1013-1013/? A/DEBUG: #02 pc 00003076 /data/app/com.Little.Aisy-2/lib/x86/libnative-activity.so
03-29 22:13:55.050 1013-1013/? A/DEBUG: #03 pc 00003ab3 /data/app/com.Little.Aisy-2/lib/x86/libnative-activity.so
03-29 22:13:55.050 1013-1013/? A/DEBUG: #04 pc 00003208 /data/app/com.Little.Aisy-2/lib/x86/libnative-activity.so (android_main+236)
03-29 22:13:55.050 1013-1013/? A/DEBUG: #05 pc 00003be5 /data/app/com.Little.Aisy-2/lib/x86/libnative-activity.so
03-29 22:13:55.050 1013-1013/? A/DEBUG: #06 pc 00081933 /system/lib/libc.so (__pthread_start(void*)+56)
03-29 22:13:55.050 1013-1013/? A/DEBUG: #07 pc 000227f2 /system/lib/libc.so (__start_thread+25)
03-29 22:13:55.050 1013-1013/? A/DEBUG: #08 pc 000170b6 /system/lib/libc.so (__bionic_clone+70)
03-29 22:13:55.180 1013-1013/? A/DEBUG: Tombstone written to: /data/tombstones/tombstone_08
03-29 22:13:55.180 1013-1013/? E/DEBUG: AM write failed: Broken pipe
Solution
From the comments, you are indicating that you are creating your context with the following call:
context = eglCreateContext(display, config, NULL, NULL);
If you use eglCreateContext with a NULL attrib_list
parameter, a GLES 1.0 context will be created. GLES 1.0 does not support shaders, thus, using glCreateProgram
will result in undefined behavior (crash in this case). To create your context with GLES 2.0 support, use the following:
EGLint contextAttribs[] =
{
EGL_CONTEXT_CLIENT_VERSION, 2, // Specifies OpenGL ES 2.0.
EGL_NONE
};
context = eglCreateContext(display, config, NULL, contextAttribs);
Answered By - MuertoExcobito
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.