HI Marcus,
My solution applies to android side with no changes to c++/PVR code.
Here are steps.
Android side
- create a GUIActivity class which will handle interactions on the android side and will either use them or pass them to the underlying AppInterface class
public class GUIActivity extends Activity
- create an AppInterface class. This is the class which the PVR will create on initialization.
public class AppInterface extends NativeActivity
- AppInterface is first created. So you must create GUIActivity when this is created
//inside AppInterface
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
context = this.getApplication().getApplicationContext();
Intent startNewActivityOpen = new Intent(this, GUIActivity.class);
startActivity(startNewActivityOpen);
}
- load PVR dll or .so inside AppInterface class
//paste this code and change the library name from PVRPlatform to whatever you use
static {
try {
System.out.println(“loading PVRPlatform …”);
System.loadLibrary(“PVRPlatform”);
System.out.println(“PVRPlatform load success”);
}
catch(UnsatisfiedLinkError e) {
System.out.println(“got unsatisfiedlinkerror boss”);
}
catch(SecurityException e) {
System.out.println(“got security exception boss”);
}
}
- mention in the manifest your acitivites
<activity android:name=“com.powervr.GLES2App.AppInterface"
android:label=”@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:launchMode="singleTask"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation=“landscape”>
<activity android:name=“com.powervr.GLES2App.GUIActivity"
android:theme=”@style/Theme.Transparent"
android:screenOrientation="landscape"
android:configChanges=“keyboard|keyboardHidden|orientation”/>
- make sure your GUIActivity is a transparent theme which means its background is always transparent.
- now you have to play with GUI controls. You can add menu into GUIActivity which gets launched first. Here I have a start button, which will call Init into appInterface and launch the game and at the same make make GUIActivity clear of all controls.
- you can pass touch events from GUIActivity down to AppInterface like this
@Override
public boolean onTouchEvent(MotionEvent ev) {
if (isViewInGameMode == true) {
if (ev.getAction() == MotionEvent.ACTION_DOWN)
AppInterface.OnTouchStart(ev.getX(), ev.getY());
else if (ev.getAction() == MotionEvent.ACTION_MOVE)
AppInterface.OnTouchUpdate(ev.getX(), ev.getY());
else if (ev.getAction() == MotionEvent.ACTION_UP)
AppInterface.OnTouchEnd(ev.getX(), ev.getY());
else {
System.out.println("action " + ev.getAction()
- " unaccounted for in OnTouchEvent");
}
}
return super.onTouchEvent(ev);
}
Let me know if you hit any snags.