Big thanks for this J-S This will give me a massive head start, I'll get downloading your code and trying to compile. I successfully got the gl2jni example working on my device (your right, that sure is a long way round and yes very basic :) )
I'm keen to get this working as I too am loving the gl2 / gles2 compatibility of osg. Means I can develop tools and test environments on windows or osx and expect roughly the same result when I move to ios (and soon hopefully android). Essentially for the OGL stuff we can remove the need for an emulator or device for a large part of the work. I'll keep you up dated Tom On 17 January 2011 14:27, Jean-Sébastien Guay < [email protected]> wrote: > Hi Thomas, > > > I've recently got my hands on a little android tablet capable of OpenGL >> ES 2.0, finally. The Archos 43, seems like it's comparable to an IPod >> touch 4th gen and pretty cheap (well compared to a Galaxy). >> > > I've got a Nexus One and am interested in compiling OSG on Android as well. > > > I like the sound of the QT port as that could help lead to a Symbian >> port also. What progress if any has anybody made? >> > > I compiled OSG with the NDK, it was pretty easy. You'll need the modified > NDK that has support for RTTI, exceptions and a more complete standard > library, which you can find here: > > http://smartctl.net/android/ndk-r4.php > > If you turn on advanced options in CMake you will see the path it uses for > C compiler, C++ compiler, linker, ar and so on, you can just change those to > the paths of those in the NDK. Then you need to add at least -nostdlib to > compile commands, and I also added a macro to help me conditionally compile > some things (-DANDROID and -D__ANDROID__ since that's what some Android > C/C++ code I've seen used). > > Apparently these things can be automated by using a toolchain file and > making a new platform in > <cmake_prefix>/share/cmake-version/Modules/Platform, but I haven't had any > luck with that. Still, I've attached the files I tried to make > (Android-toolchain.cmake and Android.cmake) in case it could be useful to > you. > > This page might help you find out what I was doing wrong: > > http://www.cmake.org/Wiki/CMake_Cross_Compiling > > Essentially you're supposed to start cmake with: > > cmake -DCMAKE_TOOLCHAIN_FILE=~/Android-toolchain.cmake .. > > and it should use the toolchain and Platform files to set compiler paths > and options automatically, but in my case it didn't do anything and I have > no idea why, so just to keep going I set these things manually. > > Then I disabled building almost everything, and just started with libosg > and went from there. I followed the settings given on the OSG Wiki OpenGL ES > page: > > http://www.openscenegraph.org/projects/osg/wiki/Community/OpenGL-ES > > which I'm sure you already know, having worked on the iOS port. I made it > build statically even though the link time is much longer because I couldn't > get the executable to find the dynamic libs (no idea how to manipulate > LD_LIBRARY_PATH so it finds libs inside the Android app bundle). > > I had to make a few small modifications to make it compile, I've also > included those as a patch, no idea how stale those changes are compared to > current trunk, I haven't updated that checkout since late December. In that > patch you'll also see where I had gotten as far as compiling OSG libraries, > I think I had osg, osgDB, osgGA, osgUtil, osgViewer, osgText and the > .osg/serializers for osg done. > > However, you may think I had gotten pretty far, but unfortunately, in > making a small program that used basic functionality (just displaying a > quad), the program always crashed at startup. Doing "printf-debugging" led > me to a place where I call setCameraManipulator(new > osgGA::TrackballManipulator). Seems it crashes in the constructor of that > class. > > I've included the code of my test app in Android.zip. In src is the Java > layer, in jni is the NDK code that should call OSG functions, and in src_x86 > is a small test program that calls the same functions but which I compile on > x86 to make sure they work. I've set up an alternate compile of OSG > according to the "Cmake settings for Emulating OpenGL ES 2.0 when you only > have standard OpenGL available" on the OSG OpenGL ES page, and that's what I > use to test the code in src_x86. > > You'll also see in the code in jni, that you can compile 2 paths: with > USE_OSG and without. The jni/Android.mk defines USE_OSG, but if you remove > it, the jni code will basically be the same as the hellogl2 sample that > comes with the NDK, and that works without crashing. > > I hope that's everything, and I especially hope you'll be able to go > forward with this and succeed where I've failed :-) I was planning on > getting back to this but haven't had time yet. > > > I'd like to try and make this a public effort from the get go by setting >> up either a google code or github project (I like google code but I know >> github to be good for keeping up to date with osg trunk changes). >> > > I think the changes to core OSG will be minimal and easy to keep track of, > but if you want to make a separate repo for the intermediate work then go > ahead. > > > I'm still working on running my first ndk based ogl app, so I've a >> little way to go before I can fully start, but just wanted to get the >> ball rolling. Think my first task will be to see if the QT port has all >> the Open GL features we require. If so I'll spend some time looking how >> they did it and report my findings. >> > > Running hellogl2 from the NDK is easy, but slightly underwhelming... First > of all GLES2 doesn't run in the emulator, so you always need a round-trip to > the phone/device. Second of all, it just displays a green triangle. Big > whoop. But hey, it shows some things at least (context creation which needs > to be done in a certain way) so it's a start. > > Also I've found that OSG's support for GLES2 is pretty cool. I can make a > scene graph that runs on regular GL2 (with vertex/normal/color arrays), add > a shader that uses the regular GL2 built-in uniforms to it > (gl_ModelViewMatrix etc.) and when I run that with a build of OSG compiled > for GLES2, it will automatically make corresponding uniforms > (osg_ModelViewMatrix etc.), convert my shader source to use them instead of > the gl_ versions, convert my arrays to use vertex attributes, and run like > that. That's pretty cool. I know it's old news for you since you've worked > on iOS which also uses GLES2, but to me who is used to working with GL2 it's > really cool to be able to use the same code to run on both platforms and > have OSG manage the details. > > Anyways, enough rambling. :-) > > I hope this helps you go forward, and I'm looking forward to seeing your > work! If you need anything else from me, just let me know! > > J-S > -- > ______________________________________________________ > Jean-Sebastien Guay [email protected] > http://www.cm-labs.com/ > http://whitestar02.webhop.org/ >
_______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

