Hi,
We had developed Java application which is running fine with JOGL and we would like to port the same on Android device.We had explored detailed steps which are required to build android application but unable to do so, due to unavailability of detailed explanation for Android platform on Jogamp.org site. Can you guys please help us by providing detailed steps which are need to build Android application using JOGL. Thanks, Akash. |
Administrator
|
On 11/05/2014 12:05 PM, akashbane [via jogamp] wrote:
> Hi, > > We had developed Java application which is running fine with JOGL and we would > like to port the same on Android device.We had explored detailed steps which > are required to build android application but unable to do so, due to > unavailability of detailed explanation for Android platform on Jogamp.org site. > > Can you guys please help us by providing detailed steps which are need to > build Android application using JOGL. Please have a look at JOGL's unit test build recipe, which also builds Android applications/activities. - jogl/make/build-test.xml - jogl/make/resources/android/AndroidManifest-test.xml Then we have an Android test within jogl-demos - jogl-demos/android/JOGLStandaloneGearsES2Test/ - jogl-demos/maven/jp4da/ (Maven: Desktop + Android .. magic) Further support may be offered by others here. You may also contact maintainers for commercial support http://jogamp.org/wiki/index.php/Maintainer_and_Contacts ~Sven > > > Thanks, > Akash. > signature.asc (828 bytes) Download Attachment |
Administrator
|
In reply to this post by akashbane
Hi
I advise you to look at this useful post: http://forum.jogamp.org/Recreating-Jogl2-Android-demo-projects-in-Eclipse-td4027079.html#a4027138
Julien Gouesse | Personal blog | Website
|
I had taken look at http://forum.jogamp.org/Recreating-Jogl2-Android-demo-projects-in-Eclipse-td4027079.html#a4027138 which you mentioned in your last post and I found that final Android-Build apk package need to be dependent on following installation packages which need to be there in Android device.
adb install gluegen-rt.apk adb install jogl.all-android.apk adb install jogl.android-launcher.apk which I found bit tricky.Can't we include source code of these apk inside our single application and generate the single application package by incorporating all these dependent packages. Please let me know if you have any other alternative way to accomplish the same. Thanks, Vicky. |
In reply to this post by gouessej
Hi,
I had gone through the above steps which are given in the link provided , for creating sample android project with jogl. We have installed all three apk's which are gluegen-rt.apk , jogl.all-android.apk , jogl.android-launcher.apk on to the device. I have kept following two jar's in the android libs folder of the project jogl-all-android-2.2.4.jar and gluegen-rt-android-2.2.4.jar But i am getting the following error after launching the application... 11-06 10:54:22.289: E/dalvikvm(1452): adjustAdaptiveCoef max=4194304, min=1048576, ut=312 11-06 10:54:22.309: E/hawaii.gralloc(1451): GRALLOC ALLOC flags 933 11-06 10:54:22.350: E/HAWAII_EGL(1451): abuffer = (480 800) (933) 11-06 10:54:22.960: E/dalvikvm(6161): dlopen("libgluegen-rt.so") failed: Cannot load library: load_library(linker.cpp:746): library "libgluegen-rt.so" not found 11-06 10:54:22.960: E/dalvikvm(6161): dlopen("/vendor/lib/libgluegen-rt.so") failed: Cannot load library: load_library(linker.cpp:746): library "/vendor/lib/libgluegen-rt.so" not found 11-06 10:54:22.960: E/dalvikvm(6161): dlopen("/system/lib/libgluegen-rt.so") failed: Cannot load library: load_library(linker.cpp:746): library "/system/lib/libgluegen-rt.so" not found 11-06 10:54:22.960: E/dalvikvm(6161): dlopen("//libgluegen-rt.so") failed: Cannot load library: load_library(linker.cpp:746): library "//libgluegen-rt.so" not found 11-06 10:54:22.990: E/AndroidRuntime(6161): FATAL EXCEPTION: main 11-06 10:54:22.990: E/AndroidRuntime(6161): java.lang.ExceptionInInitializerError 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.example.joglsample.J1_Line.onCreate(J1_Line.java:24) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.app.Activity.performCreate(Activity.java:5326) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2309) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.app.ActivityThread.access$700(ActivityThread.java:157) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1289) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.os.Handler.dispatchMessage(Handler.java:99) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.os.Looper.loop(Looper.java:176) 11-06 10:54:22.990: E/AndroidRuntime(6161): at android.app.ActivityThread.main(ActivityThread.java:5317) 11-06 10:54:22.990: E/AndroidRuntime(6161): at java.lang.reflect.Method.invokeNative(Native Method) 11-06 10:54:22.990: E/AndroidRuntime(6161): at java.lang.reflect.Method.invoke(Method.java:511) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869) 11-06 10:54:22.990: E/AndroidRuntime(6161): at dalvik.system.NativeStart.main(Native Method) 11-06 10:54:22.990: E/AndroidRuntime(6161): Caused by: java.lang.ExceptionInInitializerError 11-06 10:54:22.990: E/AndroidRuntime(6161): at javax.media.opengl.GLProfile.<clinit>(GLProfile.java:82) 11-06 10:54:22.990: E/AndroidRuntime(6161): ... 15 more 11-06 10:54:22.990: E/AndroidRuntime(6161): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: load_library(linker.cpp:746): library "//libgluegen-rt.so" not found 11-06 10:54:22.990: E/AndroidRuntime(6161): at java.lang.Runtime.load(Runtime.java:340) 11-06 10:54:22.990: E/AndroidRuntime(6161): at java.lang.System.load(System.java:521) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:468) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:63) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:94) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:332) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:390) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.jogamp.common.os.Platform$1.run(Platform.java:210) 11-06 10:54:22.990: E/AndroidRuntime(6161): at java.security.AccessController.doPrivileged(AccessController.java:45) 11-06 10:54:22.990: E/AndroidRuntime(6161): at com.jogamp.common.os.Platform.<clinit>(Platform.java:173) 11-06 10:54:22.990: E/AndroidRuntime(6161): ... 16 more 11-06 10:54:23.361: E/hawaii.gralloc(1451): GRALLOC ALLOC flags 933 11-06 10:54:23.391: E/HAWAII_EGL(1451): abuffer = (480 233) (933) 11-06 10:54:23.531: E/android.os.Debug(1962): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error 11-06 10:54:23.811: E/hawaii.gralloc(1451): GRALLOC ALLOC flags 10000b22 11-06 10:54:23.871: E/hawaii.gralloc(1451): GRALLOC ALLOC flags 10000b22 11-06 10:54:23.881: E/HAWAII_EGL(1451): abuffer = (480 800) (10000b22) 11-06 10:54:24.291: E/hawaii.gralloc(1451): GRALLOC ALLOC flags 933 11-06 10:54:24.291: E/HAWAII_EGL(1451): abuffer = (480 233) (933) 11-06 10:54:24.542: E/hawaii.gralloc(1451): GRALLOC ALLOC flags 933 11-06 10:54:24.552: E/HAWAII_EGL(1451): abuffer = (480 233) (933) Please can anybody suggest where are going wrong in terms of the implementation in for android. Thanks, Akash. |
Administrator
|
In reply to this post by Vicky Gopalani
On 11/06/2014 05:22 AM, Vicky Gopalani [via jogamp] wrote:
> I had taken look at > http://forum.jogamp.org/Recreating-Jogl2-Android-demo-projects-in-Eclipse-td4027079.html#a4027138 which > you mentioned in your last post and I found that final Android-Build apk > package need to be dependent on following installation packages which need to > be there in Android device. > adb install gluegen-rt.apk > adb install jogl.all-android.apk > adb install jogl.android-launcher.apk > > which I found bit tricky.Can't we include source code of these apk inside our > single application and generate the single application package by > incorporating all these dependent packages. > > Please let me know if you have any other alternative way to accomplish the same. you would need to use our launcher as well. The launcher adds support for utilizing multiple APKs/JARs, which is not possible otherwise. I have written about it somewhere. As an alternative, you can bundle all your classes and all contents of our APKs to your one APK and deploy it as usual. ~Sven signature.asc (828 bytes) Download Attachment |
In reply to this post by akashbane
Hi,
I have created armeabi folder in libs folder and added following files into it, libgluegen-rt.so libjoal.so libjocl.so libjogl_mobile.so libnewt.so libopenal.so But after added i am getting error as follows, 11-07 11:00:33.968: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.x11.X11GraphicsDevice', referenced from method javax.media.nativewindow.NativeWindowFactory.createDevice 11-07 11:00:33.968: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.x11.X11GraphicsDevice', referenced from method javax.media.nativewindow.NativeWindowFactory.createDevice 11-07 11:00:33.968: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.windows.WindowsGraphicsDevice', referenced from method javax.media.nativewindow.NativeWindowFactory.createDevice 11-07 11:00:33.968: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice', referenced from method javax.media.nativewindow.NativeWindowFactory.createDevice 11-07 11:00:33.968: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.x11.X11GraphicsDevice', referenced from method javax.media.nativewindow.NativeWindowFactory.createScreen 11-07 11:00:33.968: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.awt.AWTGraphicsDevice', referenced from method javax.media.nativewindow.NativeWindowFactory.createScreen 11-07 11:00:34.008: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.x11.X11GraphicsDevice', referenced from method jogamp.opengl.egl.EGLGraphicsConfigurationFactory.registerFactory 11-07 11:00:34.008: E/dalvikvm(4412): Could not find class 'com.jogamp.nativewindow.x11.X11GraphicsDevice', referenced from method jogamp.opengl.egl.EGLGraphicsConfigurationFactory.unregisterFactory 11-07 11:00:34.168: E/HAWAII_EGL(4412): Destroying surface without window 11-07 11:00:34.208: E/HAWAII_EGL(4412): Destroying surface without window Please guide me in the above error which is coming while running the android application with JOGL. Thanks, Akash. |
Administrator
|
Hi
You must use neither jogl-all nor jogl-mobile, you must just jogl-android and gluegen-rt-android (and their native libraries) so that Dalvik / ART won't try to load classes for desktop environment. Look at jp4da to understand which native libraries and which JARs to use: https://github.com/sgothel/jogl-demos/blob/master/maven/jp4da/jp4da-android/pom.xml
Julien Gouesse | Personal blog | Website
|
Hi,
Thanks for your help I had successfully deployed first android demo app with JOGL on device. My current desktop app use GL2 capabilities and current android version JOGL demo app uses GL2ES2 capabilities which has altogether different api's. So can I deploy GL2 capabilites on android device,I had tried but as such getting null pointer exception ComponentInfo{com.example.joglsample2android/com.example.joglsample2android.MainActivity}: javax.media.opengl.GLException: Profile GL2 is not available on null. Thanks, Vicky |
Administrator
|
I advise you to look at this document to understand how things work, ES, etc...:
http://jogamp.org/jogl/doc/Overview-OpenGL-Evolution-And-JOGL.html There is some kind of fixed pipeline emulation that you can use to make your code work with both GL2 and GL2ES2, look at com.jogamp.opengl.util.glsl.fixedfunc.FixedFuncUtil and there is at least one demo using it in jogl-demos. I'm happy to see that you've made some progress.
Julien Gouesse | Personal blog | Website
|
In reply to this post by Vicky Gopalani
One solution would be to use the GL2ES2 capabilities on desktop as well such a setup would make sure that you only use the common subset of functionality that is part of both desktop opengl 2 and mobile opengl es 2 hardware drivers. 2014-11-07 13:00 GMT+01:00 Vicky Gopalani [via jogamp] <[hidden email]>: Hi, |
Hi
I had tried to run demo RedSquare example on desktop and android it worked fine. I had started to work on GL2ES2 and trying to create demo app which plot a point on screen as soon as mouse click is performed in case of desktop and screen click in case of mobile. Here is my code which I had taken reference from ReqSquare demo example public class GLPoint extends GLWindow implements GLEventListener, com.jogamp.newt.event.MouseListener { private ShaderState st; private PMVMatrix pmvMatrix; private GLUniformData pmvMatrixUniform; private GLArrayDataServer vertices; private GLArrayDataServer colors; private int swapInterval = 0; private float aspect = 1.0f; private boolean clearBuffers = true; private ArrayList<Float> mouseX = new ArrayList<Float>(); private ArrayList<Float> mouseY = new ArrayList<Float>(); protected GLPoint(Window arg0) { super(arg0); this.swapInterval = 1; addGLEventListener(this); addMouseListener(this); } public void setAspect(final float aspect) { this.aspect = aspect; } public void setClearBuffers(final boolean v) { clearBuffers = v; } @Override public void init(final GLAutoDrawable glad) { final GL2ES2 gl = glad.getGL().getGL2ES2(); System.err.println("RedSquareES2 init on " + Thread.currentThread()); System.err.println("Chosen GLCapabilities: " + glad.getChosenGLCapabilities()); System.err.println("INIT GL IS: " + gl.getClass().getName()); System.err .println(JoglVersion.getGLStrings(gl, null, false).toString()); if (!gl.hasGLSL()) { System.err.println("No GLSL available, no rendering."); return; } st = new ShaderState(); st.setVerbose(true); final ShaderCode vp0 = ShaderCode.create(gl, GL2ES2.GL_VERTEX_SHADER, this.getClass(), "shader", "shader/bin", "RedSquareShader", true); final ShaderCode fp0 = ShaderCode.create(gl, GL2ES2.GL_FRAGMENT_SHADER, this.getClass(), "shader", "shader/bin", "RedSquareShader", true); vp0.defaultShaderCustomization(gl, true, true); fp0.defaultShaderCustomization(gl, true, true); final ShaderProgram sp0 = new ShaderProgram(); sp0.add(gl, vp0, System.err); sp0.add(gl, fp0, System.err); st.attachShaderProgram(gl, sp0, true); // setup mgl_PMVMatrix pmvMatrix = new PMVMatrix(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmvMatrix.glLoadIdentity(); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrixUniform = new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()); // P, Mv st.ownUniform(pmvMatrixUniform); st.uniform(gl, pmvMatrixUniform); // Allocate Vertex Array //allocateVertexArray(gl); // Allocate Color Array //allocateColorArray(gl); // OpenGL Render Settings gl.glEnable(GL.GL_DEPTH_TEST); st.useProgram(gl, false); System.err.println(Thread.currentThread() + " RedSquareES2.init FIN"); } public void allocateVertexArray(GL2ES2 gl) { vertices = GLArrayDataServer.createGLSL("mgl_Vertex", 3, GL.GL_FLOAT, false, mouseX.size(), GL.GL_STATIC_DRAW); for(int i=0;i<mouseX.size();i++) { /*vertices.putf(1); vertices.putf(0);*/ /*vertices.putf(111); vertices.putf(230);*/ vertices.putf(mouseX.get(i)); vertices.putf(mouseY.get(i)); } vertices.seal(gl, true); st.ownAttribute(vertices, true); vertices.enableBuffer(gl, false); } public void allocateColorArray(GL2ES2 gl) { colors = GLArrayDataServer.createGLSL("mgl_Color", 4, GL.GL_FLOAT, false,mouseX.size() , GL.GL_STATIC_DRAW); for(int i=0;i<mouseX.size();i++) { colors.putf(0); colors.putf(0); colors.putf(1); colors.putf(1); } colors.seal(gl, true); st.ownAttribute(colors, true); colors.enableBuffer(gl, false); } @Override public void display(final GLAutoDrawable glad) { final GL2ES2 gl = glad.getGL().getGL2ES2(); if (clearBuffers) { gl.glClearColor(0, 0, 0, 0); gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); } if (!gl.hasGLSL()) { return; } st.useProgram(gl, true); pmvMatrix.glMatrixMode(GLMatrixFunc.GL_MODELVIEW); pmvMatrix.glLoadIdentity(); pmvMatrix.glTranslatef(0, 0, -10); st.uniform(gl, pmvMatrixUniform); // Draw a point if(mouseX.size()<=0) return; allocateVertexArray(gl); allocateColorArray(gl); vertices.enableBuffer(gl, true); colors.enableBuffer(gl, true); gl.glDrawArrays(GL.GL_POINTS, 0, mouseX.size()); vertices.enableBuffer(gl, false); colors.enableBuffer(gl, false); st.useProgram(gl, false); } int width,height; @Override public void reshape(final GLAutoDrawable glad, final int x, final int y, final int width, final int height) { final GL2ES2 gl = glad.getGL().getGL2ES2(); if (-1 != swapInterval) { gl.setSwapInterval(swapInterval); } this.width = width; this.height = height; reshapeImpl(gl, x, y, width, height, width, height); } void reshapeImpl(final GL2ES2 gl, final int tileX, final int tileY, final int tileWidth, final int tileHeight, final int imageWidth, final int imageHeight) { if (!gl.hasGLSL()) { return; } st.useProgram(gl, true); // Set location in front of camera pmvMatrix.glMatrixMode(GLMatrixFunc.GL_PROJECTION); pmvMatrix.glLoadIdentity(); // compute projection parameters 'normal' perspective final float fovy = 45f; final float aspect2 = ((float) imageWidth / (float) imageHeight) / aspect; final float zNear = 1f; final float zFar = 100f; // compute projection parameters 'normal' frustum final float top = (float) Math.tan(fovy * ((float) Math.PI) / 360.0f) * zNear; final float bottom = -1.0f * top; final float left = aspect2 * bottom; final float right = aspect2 * top; final float w = right - left; final float h = top - bottom; // compute projection parameters 'tiled' final float l = left + tileX * w / imageWidth; final float r = l + tileWidth * w / imageWidth; final float b = bottom + tileY * h / imageHeight; final float t = b + tileHeight * h / imageHeight; pmvMatrix.glFrustumf(l, r, b, t, zNear, zFar); st.uniform(gl, pmvMatrixUniform); st.useProgram(gl, false); System.err .println(Thread.currentThread() + " RedSquareES2.reshape FIN"); } @Override public void dispose(final GLAutoDrawable glad) { final GL2ES2 gl = glad.getGL().getGL2ES2(); if (!gl.hasGLSL()) { return; } st.destroy(gl); st = null; pmvMatrix = null; System.err .println(Thread.currentThread() + " RedSquareES2.dispose FIN"); } @Override public void mouseClicked(MouseEvent arg0) { System.out.println("Mouse Clicked X" + arg0.getX() + " "); System.out.println("Mouse Clicked Y" + arg0.getY() + " "); float coor[] = getWorldCoordinate(arg0.getX(),arg0.getY()); System.out.println("Converting........."); System.out.println("X="+coor[0]); System.out.println("Y="+coor[1]); mouseX.add(coor[0]); mouseY.add(coor[1]); } @Override public void mouseDragged(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseEntered(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseExited(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseMoved(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mousePressed(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseReleased(MouseEvent arg0) { // TODO Auto-generated method stub } @Override public void mouseWheelMoved(MouseEvent arg0) { // TODO Auto-generated method stub } private float[] getWorldCoordinate( int x, int y) { int[] viewport = {0, 0, width, height}; float[] obje = new float[3]; pmvMatrix.gluUnProject((float)x, (float)y, (float)0, viewport, 0, obje , 0); return obje; } } ReqSquare.vp // Copyright 2010 JogAmp Community. All rights reserved. #if __VERSION__ >= 130 #define attribute in #define varying out #endif uniform mat4 mgl_PMVMatrix[2]; attribute vec4 mgl_Vertex; attribute vec4 mgl_Color; varying vec4 frontColor; void main(void) { frontColor=mgl_Color; gl_Position = mgl_PMVMatrix[0] * mgl_PMVMatrix[1] * mgl_Vertex; gl_PointSize = 10.0; } ReqSquare.fp // Copyright 2010 JogAmp Community. All rights reserved. #if __VERSION__ >= 130 #define varying in out vec4 mgl_FragColor; #else #define mgl_FragColor gl_FragColor #endif varying vec4 frontColor; void main (void) { mgl_FragColor = frontColor; } Points are getting draw surrounding the screen center not on the screen coordinate position where mouse clicked is performed. Any help would be highly appreciated. Thanks, Vicky |
Free forum by Nabble | Edit this page |