Author Topic: Android Developement Log  (Read 1288 times)

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Android Developement Log
« on: April 16, 2013, 02:22:14 AM »
Getting QB64 to work on Android is going to take some time. OpenGL ES will have to be used for screen updates and the native language for Android is Java. Luckily Android provides the NDK (native development kit) which allows us to compile C/C++ code [small sigh of relief]. I've restarted my Android development and as of today I have got some of the OpenGL NDK sames to compile and work on the emulator. It's not a massive leap to replace bits of this example with parts from QB64.

I should emphasize, I do not intend to get the QB64 IDE/compiler to run on Android (well not for now anyway 8)), only to get QB64 to spit out Android compatible source code.

Anyhow, I'll post here whenever I have something to report. If you are an android developer I'm all ears about ideas to streamline the support process.
Something old... Something new... Something borrowed... Something blue...

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: Android Developement Log
« Reply #1 on: April 16, 2013, 06:45:55 AM »
I've started moving non-dependent sections of libqb.cpp into my (now c++ not c) native activity. So far it detects Android and avoids glut initialization, that's about it.
Something old... Something new... Something borrowed... Something blue...

Coolman

  • Jr. Member
  • **
  • Posts: 81
Re: Android Developement Log
« Reply #2 on: April 16, 2013, 07:08:26 AM »

http://android-developers.blogspot.com/2011/01/gingerbread-ndk-awesomeness.html
*** Excuse my English, I use google translate ***

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Android Developement Log
« Reply #3 on: April 17, 2013, 01:41:38 AM »
Hi all,
   
Code: [Select]
I should emphasize, I do not intend to get the QB64 IDE/compiler to run on Android (well not for now anyway ), only to get QB64 to spit out Android compatible source code.    How do we compile it then?
OlDosLover.

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: Android Developement Log
« Reply #4 on: April 17, 2013, 02:57:13 AM »
I note there is a page saying Android support is available from a version which doesn't seem to exist on the FreeGLUT website:
http://freeglut.sourceforge.net/docs/android.php
I note that there are no references to Android or OpenGL ES in the current release of FreeGLUT.
I note that elsewhere there are references to Android, but that it states these have been integrated into the main branch of FreeGLUT.
http://freeglut.svn.sourceforge.net/viewvc/freeglut/trunk/freeglut/freeglut/src/
I'm a bit confused about this disconnect.
For now I've removed all GLUT references from the stub QB64 program I'm trying to compile so no input or (graphical) output. I'll sort out the FreeGLUT issue later. So far the process is continuing reasonably well in that libqb.cpp appears to compile (with all GLUT & GL references stripped out). I haven't gotten to qbx.cpp yet, but that will be the next step.

Quote
How do we compile it then?
QB64 doesn't, you do. Essentially you'd write the program and perform primary testing in QB64 on your primary development OS (Windows, MacOSX or Linux) and (with the appropriate checkbox selected in the QB64 IDE) QB64 also spits out an "Android project" which can be compiled and launched in an android supporting environment of your choice (I'm using Eclipse with the Android SDK & NDK). I'll be providing tutorials on how to setup these things (which can be tricky to set up if you miss a step). QB64 will provide some helpful features like calling 'ndk-build' automatically on your Android projects if desired. As I learn more about the Android SDK & NDK I may be able to scaffold the process even further, such as providing a version of QB64 which comes with QB64+AndroidSDK&NDK+Emulator' and lets you test your program more directly. I suspect we'll also see some interest from the Android community as this element of QB64 gathers speed.
Something old... Something new... Something borrowed... Something blue...

fluffrabbit

  • Sr. Member
  • ****
  • Posts: 393
Re: Android Developement Log
« Reply #5 on: April 17, 2013, 03:10:52 AM »
Wow, a full project will be generated? I just thought it would be some C++ source files. I am getting pretty pumped.

Hopefully, it will be straightforward to make a library that unifies Android-specific and PC-specific things such as multitouch, mouse support, etc.

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: Android Developement Log
« Reply #6 on: April 17, 2013, 03:16:40 AM »
Quote
Hopefully, it will be straightforward to make a library that unifies Android-specific and PC-specific things such as multitouch, mouse support, etc.
That's why it'd be good (but not essential) to get FreeGLUT working here.
Something old... Something new... Something borrowed... Something blue...

fluffrabbit

  • Sr. Member
  • ****
  • Posts: 393
Re: Android Developement Log
« Reply #7 on: April 17, 2013, 03:34:34 AM »
Quote
Hopefully, it will be straightforward to make a library that unifies Android-specific and PC-specific things such as multitouch, mouse support, etc.
That's why it'd be good (but not essential) to get FreeGLUT working here.

As far as I was aware, FreeGLUT is little more than an OpenGL wrapper. Surely, calls to OpenGL and OpenGL-ES would be the same. I was just talking about more superficial functionality like user input. Is FreeGLUT proving to be a challenge? What functionality does FreeGLUT provide? It says that FreeGLUT version 3.0 supports Android. It says under TODO:

Quote
Multi-touch support (glutMultiMotionFunc & al.)
Display translucent keys on virtual keypad
API to access raw JVM structure and raw Activity(ies?) structure
API to detect touchscreen presence
API (or configuration file?) to disable assets extraction
Accelerometer as a joystick input

This is starting to look like a monumental challenge.

OlDosLover

  • Hero Member
  • *****
  • Posts: 3859
  • OlDosLover
    • Email
Re: Android Developement Log
« Reply #8 on: April 17, 2013, 03:43:31 AM »
Hi all,
    Wow! Again.
Quote
As I learn more about the Android SDK & NDK I may be able to scaffold the process even further, such as providing a version of QB64 which comes with QB64+AndroidSDK&NDK+Emulator' and lets you test your program more directly. I suspect we'll also see some interest from the Android community as this element of QB64 gathers speed.
    Well i support you and wish you speedy success!

Have you seen this site?
http://www.basic4ppc.com/index.html
    If you would like a better looky then email me for the more comprehensive version if you so wish.
OlDosLover.

fluffrabbit

  • Sr. Member
  • ****
  • Posts: 393
Re: Android Developement Log
« Reply #9 on: April 17, 2013, 03:57:07 AM »
Oh, how it angers me when such a simple idea can be marketed so effectively.

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: Android Developement Log
« Reply #10 on: April 17, 2013, 07:14:46 AM »
Code: [Select]
t! = TIMER
DO
    'this program does nothing
    _LIMIT 30
    IF TIMER > t! + 10 THEN SYSTEM
LOOP
It may be a very boring program, what isn't so boring about it it that I just run it in Android. As I didn't have any display surface or sound, the most powerful output I had was for the program to exit, which it did after exactly 10 seconds.

Well actually I lie, I do have a display surface which is the example's surface displaying random colors. So all I need to do is get my screen buffer onto that surface and...
Something old... Something new... Something borrowed... Something blue...

fluffrabbit

  • Sr. Member
  • ****
  • Posts: 393
Re: Android Developement Log
« Reply #11 on: April 17, 2013, 07:22:54 AM »
It sounds like things are coming along quite nicely. Android has its own GL libraries, so I don't really know where FreeGLUT fits into this, but however you do it, I am looking forward to seeing OpenGL output on Android. Awesome.

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: Android Developement Log
« Reply #12 on: April 17, 2013, 03:47:36 PM »
Quote
It sounds like things are coming along quite nicely. Android has its own GL libraries, so I don't really know where FreeGLUT fits into this
It's all about OS specific abstraction. The more you can abstract, with or without the help of a library, the more portable your product becomes. FreeGLUT provides simple commands for window creation, managing input and a few other peripheral things like setting the window name. Yes, I could code a specific implementation of all of these things for every operating system QB64 supports but these are so generic that I may as well use someone else's code. What I like about GLUT is that it is minimalist, therefore if there is not GLUT wrapper for an OS you can simply implement the commands yourself. I'm currently establishing if the Android GLUT implementation posted above is usable.
Something old... Something new... Something borrowed... Something blue...

fluffrabbit

  • Sr. Member
  • ****
  • Posts: 393
Re: Android Developement Log
« Reply #13 on: April 17, 2013, 04:57:47 PM »
Well, good luck on that Android GLUT. It currently looks like there is no input functionality in it, and it doesn't facilitate any Java interface. I haven't used Android enough to know how this affects things. It sounds like it just serves to output GL graphics, but to where? If you could direct it to an existing surface/view/interface/activity, might it serve your purposes better, or does FreeGLUT make the "window" on Android, and what is the "window"? I assume that the example's surface is going to be pretty useless when using FreeGLUT unless I'm mistaken. I would think FreeGLUT would want to go make a new one, but at what level?

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 4664
  • QB Forever
    • Email
Re: Android Developement Log
« Reply #14 on: April 18, 2013, 07:18:05 PM »
Well, it took about 10 hours of blundering around, but I've got FreeGLUT implemented into the Android build which means in theory I've got mouse input, keyboard input and graphical output. I pulled it back from OpenGLES2 to OpenGLES1 (the code I found was only setup for OpenGLES2) but later I'll allow people to select which one they want with a meta-command. The only issue to deal with now is getting the screen's pixel buffer onto the actual surface, which will require some changes to a function which is not setup for GL ES, this should be fairly straightforward.

This is looking very promising. 8)
Something old... Something new... Something borrowed... Something blue...