Hi!
- Build iosglkview branch
- Create new libgdx project with ios-moe module
- Replace ‘IOSMoeLauncher’ code to:
@RegisterOnStartup
public class IOSMoeLauncher extends NSObject implements UIApplicationDelegate {
public static void main(String[] args) {
UIKit.UIApplicationMain(0, null, null, IOSMoeLauncher.class.getName());
}
@Selector("alloc")
public static native IOSMoeLauncher alloc();
protected IOSMoeLauncher(Pointer peer) {
super(peer);
}
private UIWindow window;
@Override
public void setWindow(UIWindow value) {
window = value;
}
@Override
public UIWindow window() {
return window;
}
}
- Create new ui package
- Create ‘AppViewController extends UIViewController’ class in the ui package
- Add to class:
@Selector("iosglkView")
@Property
@IBOutlet
public native IOSGLKView getIOSGLKView();
and this code to ‘viewDidLoad’ method:
IOSApplicationConfiguration configuration = new IOSApplicationConfiguration();
iosViewApplication = new IOSGLKViewApplication(new MyGdxGame(), configuration);
iosViewApplication.initializeForView(getIOSGLKView());
See:
@org.moe.natj.general.ann.Runtime(ObjCRuntime.class)
@ObjCClassName("AppViewController")
@RegisterOnStartup
public class AppViewController extends UIViewController {
@Owned
@Selector("alloc")
public static native AppViewController alloc();
@Selector("init")
public native AppViewController init();
protected AppViewController(Pointer peer) {
super(peer);
}
IOSGLKViewApplication iosViewApplication;
@Override
public void viewDidLoad() {
super.viewDidLoad();
IOSApplicationConfiguration configuration = new IOSApplicationConfiguration();
iosViewApplication = new IOSGLKViewApplication(new MyGdxGame(), configuration);
iosViewApplication.initializeForView(getIOSGLKView());
}
@Selector("iosglkView")
@Property
@IBOutlet
public native IOSGLKView getIOSGLKView();
}
- Run ‘Generate actions and Outlets for Interface Builder’
- Open Project in Xcode
- Create Main.storyboard
- Set Main Interface to Main
- Add ‘View Controller’ to storyboard, and select ‘Is Initial View Controller’
- Set ‘View Controller’ Custom Class to ‘AppViewController’
- Add GLKView to controller and set Custom Class to ‘IOSGLKView’
- Show ‘Assistant Editor’
- Select ‘moe-main-interfaces.m’ and connect GLKView to iosglkView property
- Return to IDE and run application
Sample application: IOSGLKViewApplication.zip (742.8 KB)
Best Regards,
Roland