7

I tried the test-libstdc++ demo and liked that I can start it from the console and all without running a full-grown android application.

I'd like to create an opengl context so that I'd be able to execute my opengl es 2.0 app from within the console without too many bothering.

Any idea how could I initialize the EGL from within a NDK-app that doesn't use native activity or anything, i.e. it is not even packaged in a .APKK file, just has a main method is packed as an executable linux file.

Thanks a lot!

UPDATE

Does it by any chance has anything to do with ANativeWindow_acquire in *android/native_window.h`?

Thanks!

Albus Dumbledore
  • 12,368
  • 23
  • 64
  • 105
  • How to do this without downloading the entire Android OS source code? I prefer ndk-build.cmd, but Ubuntu gcc is okay too... http://stackoverflow.com/questions/21280393/how-can-i-create-a-new-nativewindow-in-android-ndk-without-needing-the-android-o – pemcode Jan 22 '14 at 10:33

2 Answers2

2

If you look inside the git trees for Android, you will see that there are several simple test apps that create a native window and are launched from the command line.

click here to see the tests

Regarding the questions to some of the comments above by Albus, the issue with the flip chain is because your current driver can only support 1 flip chain in the system, and that's being held by SurfaceFlinger since that's the entity who can write to the native window/framebuffer. To work around this you can just stop the Android Run Time engine by typing 'stop' inside adb shell, then re-run your app. To get the Android Run time engine back up, do 'start'.

csanta
  • 512
  • 4
  • 5
1

Here's an example of using EGL from command line:

http://jiggawatt.org/badc0de/android/index.html

However such process without 'legal' Android UI Activity is going to be killed by the system at any time for being considered as a background process. Also you wouldn't be able you use touchscreen or keyboard input, or any other stuff that require Context, like figuring out where the SD card is mounted, etc.

ognian
  • 11,451
  • 4
  • 35
  • 33
  • Thanks a lot! That's exactly what I'm trying to do. Generally, my app would run for a very short period of time - several secs at most. I just would like to test the rendering abilities on the video card from within the Android OS, using my old C OGLES2 code without much changes. The general idea of the app is to do some simple image processing using OGLES2 & fragment shaders. It does work on my ubuntu (using the powervr headers & libs). – Albus Dumbledore Mar 21 '11 at 16:16
  • Upon looking more closely at the code it looks ***exactly*** what I'd like to use. I'm only hoping it would really work in the end. :-) Thanks! – Albus Dumbledore Mar 21 '11 at 16:20
  • 1
    This code is an old gem, before the time of NDK and it worked flawlessly then. I suggest that you use the libEGL from NDK r5 instead of pulling it from some device – ognian Mar 21 '11 at 18:55
  • I'd certainly use that. Thanks! – Albus Dumbledore Mar 21 '11 at 19:29
  • Unfortunately, it gives an error when android_createDisplaySurface() is called: `ERROR: Swap chain already exists for display 2` Any ideas? Thanks! – Albus Dumbledore Mar 22 '11 at 13:43
  • That error is completely baffling since it uses microsoft terminology that has noting to do with OpenGL... In Android source tree, see /external/quake/standalone/main.cpp for a sample usage of that function. Do you get other errors like 'couldn't open framebuffer HAL'? – ognian Mar 22 '11 at 15:06
  • I tried the EGL demo, too. I mean, I tried to run the compiled binary from the demo you showed me and got the same error. I can't help thinking it's got something to do with my testing device. I'm using OMAP Blaze. Thanks! – Albus Dumbledore Mar 23 '11 at 08:20