1

Can anyone suggest how start learning Open GL implementation in pure C++ in a NativeActivity in Android NDK without using jni.

I have tried running the sample NativeActivity that comes with the NDK setup, but I am not able to run it. Giving error

Type 'EGL_DEFAULT_DISPLAY' could not be resolved

Can anyone suggest how to resolve this error.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Mayank
  • 1,099
  • 4
  • 17
  • 44
  • The answer is one google search away. – user1095108 Mar 03 '14 at 10:14
  • the results i am getting is to use Open GL from Java and C++ using jni. I want ot use it purely in C++ and not from Java – Mayank Mar 03 '14 at 10:15
  • http://developer.android.com/reference/android/app/NativeActivity.html – user1095108 Mar 03 '14 at 10:17
  • I tried running this exmaple on my phone using eclipse but it gives error `Type 'EGL_DEFAULT_DISPLAY' could not be resolved` – Mayank Mar 03 '14 at 10:53
  • Could be anything, debug. On one of my tablets, the Java example of `GLSurfaceView` does not work either any if anything should work, that definetly should. I suggest, you change your question to ask about the error. – user1095108 Mar 03 '14 at 11:37

3 Answers3

1

Resolved the error

just add the statement typedef void* EGLNativeDisplayType; before the statement #include <EGL/egl.h> in main.c in the NativeActivity

Mayank
  • 1,099
  • 4
  • 17
  • 44
  • It's not a good idea to define platform-specific types yourself. This should be coming out of `EGL/eglplatform.h`. The part I don't understand, looking at your question, is why the compiler would claim that `EGL_DEFAULT_DISPLAY` is a *type*. – fadden Mar 03 '14 at 15:48
  • you are absolutely correct, but when I was checking out the header file `EGL/eglplatform.h`, I found that its definition is dependent on the macros `__ANDROID__` or `ANDROID`. May be the problem lies in this only. – Mayank Mar 04 '14 at 06:01
  • IIRC, those should be defined for you by the Android NDK compiler configuration. – fadden Mar 04 '14 at 06:27
  • true. but I am not able to figure out the option from where I can define it for my NDK compiler configuration. – Mayank Mar 04 '14 at 06:38
  • Should be baked in -- see http://stackoverflow.com/questions/2224334/gcc-dump-preprocessor-defines for instructions on how to get the list. When I use that on with the NDK gcc, I see (among 350 other things) `#define __ANDROID__ 1`. – fadden Mar 04 '14 at 17:29
0

Can be handled by including source SUB directories as well as their parents in project > properties >C/C++ General > Paths and Symbols > Includes(tab).

e.g. add

${env_var:ANDROID_NDK}/platforms/android-19/arch-arm/usr/include/EGL

as well as

${env_var:ANDROID_NDK}/platforms/android-19/arch-arm/usr/include

Maybe the syntax parser (if there is such a thing) misses the sub-folders?

Wesley Bland
  • 8,816
  • 3
  • 44
  • 59
0

include the ${env_var:ANDROID_NDK}/platforms/android-19/arch-arm/usr/include/EGL is a partial correct, after this, comment out all content in Application.mk, then close main.c, clean the project, open main.c again, see the error is disappear, then recovery the Application.mk.

applixy
  • 873
  • 6
  • 5