add vtm-gdx-ios

This commit is contained in:
Hannes Janetzek 2014-02-27 03:45:36 +01:00
parent 3cda9684cb
commit 1c4979bdaa
16 changed files with 550 additions and 24 deletions

1
.gitignore vendored
View File

@ -17,7 +17,6 @@ build/
/vtm-gdx-desktop/assets/
/vtm-gdx-html/war/
/vtm-gdx-html/gwt-unitCache
/vtm-gdx-ios/
/vtm-spatialite/
/vtm-spatialite-android/
/vtm-examples/

View File

@ -17,8 +17,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>

View File

@ -1,25 +1,14 @@
<project name="vtm-jni-natives" basedir="." default="all">
<target name="clean">
<ant antfile="build-windows32.xml" target="clean"/>
<ant antfile="build-windows64.xml" target="clean"/>
<ant antfile="build-linux64.xml" target="clean"/>
<ant antfile="build-android32.xml" target="clean"/>
</target>
<target name="compile-natives">
<ant antfile="build-windows32.xml"/>
<ant antfile="build-windows64.xml"/>
<ant antfile="build-linux64.xml"/>
<ant antfile="build-android32.xml"/>
</target>
<target name="pack-natives">
<jar destfile="../libs/vtm-jni-natives.jar">
<fileset dir="../libs/windows32" includes="vtm-jni.dll"/>
<fileset dir="../libs/windows64" includes="vtm-jni64.dll"/>
<fileset dir="../libs/linux64" includes="libvtm-jni64.so"/>
</jar>
</target>

View File

@ -81,11 +81,11 @@ public class JniBuilder {
android.cppFlags += cflags;
android.linkerFlags += " -llog";
// BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false);
// ios.headerDirs = headers;
// ios.cIncludes = sources;
// ios.cFlags += cflags;
// ios.cppFlags += cflags;
BuildTarget ios = BuildTarget.newDefaultTarget(TargetOs.IOS, false);
ios.headerDirs = headers;
ios.cIncludes = sources;
ios.cFlags += cflags;
ios.cppFlags += cflags;
//new NativeCodeGenerator().generate();
new AntScriptGenerator().generate(new BuildConfig("vtm-jni"),
@ -94,8 +94,9 @@ public class JniBuilder {
// win32,
// win64,
// lin32,
lin64,
android);
//lin64,
//android
ios);
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v clean");
// BuildExecutor.executeAnt("jni/build-windows32home.xml", "-v");

View File

@ -2,10 +2,10 @@ include ':vtm'
include ':vtm-extras'
include ':vtm-android'
include ':vtm-android-example'
include ':vtm-android-app'
include ':vtm-themes'
include ':vtm-gdx'
include ':vtm-gdx-desktop'
include ':vtm-gdx-android'
include ':vtm-android-app'
include ':vtm-themes'
//include ':vtm-gdx-html'
//include ':vtm-ext-libs'
include ':vtm-gdx-html'
include ':vtm-gdx-ios'

@ -1 +1 @@
Subproject commit 0bf68282155798f3884a4635e52fbbc90a0e5cc6
Subproject commit 92d16812200c396536bbfd5a5aa34ee08084e26c

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${app.name}</string>
<key>CFBundleExecutable</key>
<string>${app.executable}</string>
<key>CFBundleIdentifier</key>
<string>${app.id}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${app.name}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${app.version}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${app.build}</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false />
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon</string>
<string>Icon-72</string>
</array>
</dict>
</dict>
</dict>
</plist>

69
vtm-gdx-ios/build.gradle Normal file
View File

@ -0,0 +1,69 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.github.jtakakura:gradle-robovm-plugin:0.0.4'
}
}
repositories {
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
apply plugin: 'java'
apply plugin: 'robovm'
ext {
// Configure your application main class
mainClassName = "org.oscim.ios.RoboVmLauncher"
//roboVMVersion = "0.0.9"
}
dependencies {
compile project(':vtm-gdx')
compile project(':vtm-themes')
compile 'org.slf4j:slf4j-simple:1.7.5'
compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
}
sourceCompatibility = '1.7'
//[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
robovm {
// Configure robovm
iosSignIdentity = ""
iosProvisioningProfile = ""
}
sourceSets {
main {
java.srcDirs = ['src/']
//resources.srcDirs = ['src/', 'data']
}
output.resourcesDir = 'assets'
}
// compile bytecode to llvm and run in the ios simulator
// task run (dependsOn: compileJava){
// doFirst {
// println(">> Running RoboVM")
// String cmd = "$project.robovm_home/bin/robovm -verbose -arch x86 -os ios -cp $project.robovm_home/lib/robovm-objc.jar:$project.robovm_home/lib/robovm-cocoatouch.jar:$projectDir/build/classes/main/ -run $mainClass"
// def proc = cmd.execute()
// proc.in.eachLine {line -> println line}
// proc.err.eachLine {line -> System.err.println( 'ERROR: ' + line)}
// proc.waitFor()
// }
// }
eclipse {
project {
natures = [ 'org.eclipse.jdt.core.javanature',
'org.robovm.eclipse.RoboVMNature']
buildCommand 'org.robovm.eclipse.RoboVMClassBuilder'
}
}

View File

@ -0,0 +1,8 @@
#
#Fri May 31 13:01:40 CEST 2013
app.version=1.0
app.id=com.noxymo.opensciencemap
app.mainclass=org.oscim.ios.RobovmLauncher
app.executable=VtmApp
app.build=1
app.name=VectorMap

37
vtm-gdx-ios/robovm.xml Normal file
View File

@ -0,0 +1,37 @@
<config>
<executableName>${app.executable}</executableName>
<mainClass>${app.mainclass}</mainClass>
<os>ios</os>
<arch>thumbv7</arch>
<target>ios</target>
<iosInfoPList>Info.plist.xml</iosInfoPList>
<resources>
<resource>
<directory>../vtm-themes/resources/assets</directory>
<includes>
<include>**</include>
</includes>
<skipPngCrush>true</skipPngCrush>
</resource>
<resource>
<directory>data</directory>
</resource>
</resources>
<forceLinkClasses>
<pattern>com.badlogic.gdx.scenes.scene2d.ui.*</pattern>
</forceLinkClasses>
<libs>
<lib>../vtm-ext-libs/ios/libgdx.a</lib>
<lib>../vtm-ext-libs/ios/libObjectAL.a</lib>
<lib>../vtm-ext-libs/ios/libvtm-jni.a</lib>
</libs>
<frameworks>
<framework>UIKit</framework>
<framework>OpenGLES</framework>
<framework>QuartzCore</framework>
<framework>CoreGraphics</framework>
<framework>OpenAL</framework>
<framework>AudioToolbox</framework>
<framework>AVFoundation</framework>
</frameworks>
</config>

View File

@ -0,0 +1,61 @@
package org.oscim.ios;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.GLAdapter;
import org.oscim.gdx.GdxMap;
import org.oscim.ios.backend.IosGLAdapter;
import org.oscim.ios.backend.IosGraphics;
import org.oscim.layers.tile.vector.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource;
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
import org.robovm.cocoatouch.foundation.NSAutoreleasePool;
import org.robovm.cocoatouch.glkit.GLKViewDrawableStencilFormat;
import org.robovm.cocoatouch.uikit.UIApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
public class RobovmLauncher extends IOSApplication.Delegate {
@Override
protected IOSApplication createApplication() {
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
config.orientationLandscape = true;
config.orientationPortrait = true;
config.stencilFormat = GLKViewDrawableStencilFormat.Format8;
return new IOSApplication(new GdxMap() {
@Override
public void createLayers() {
TileSource tileSource = new OSciMap4TileSource();
//initDefaultLayers(tileSource, false,true, false);
VectorTileLayer l = mMap.setBaseMap(tileSource);
mMap.setTheme(VtmThemes.TRON2);
mMap.layers().add(new BuildingLayer(mMap, l));
mMap.layers().add(new LabelLayer(mMap, l));
// mMap.getLayers().add(new GenericLayer(mMap, new
// GridRenderer(1,new Line(Color.LTGRAY, 1.2f),null)));
mMap.setMapPosition(53.1, 8.8, 1 << 14);
}
}, config);
}
public static void main(String[] argv) {
NSAutoreleasePool pool = new NSAutoreleasePool();
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
CanvasAdapter.g = IosGraphics.get();
GLAdapter.g = new IosGLAdapter();
UIApplication.main(argv, null, RobovmLauncher.class);
pool.drain();
}
}

View File

@ -0,0 +1,77 @@
package org.oscim.ios.backend;
import java.io.IOException;
import java.io.InputStream;
import org.oscim.backend.canvas.Bitmap;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.g2d.Gdx2DPixmap;
public class IosBitmap implements Bitmap {
Pixmap pixmap;
boolean disposable;
/** always argb8888 */
public IosBitmap(int width, int height, int format) {
pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
}
public IosBitmap(String fileName) {
FileHandle handle = Gdx.files.internal(fileName);
pixmap = new Pixmap(handle);
disposable = true;
}
public IosBitmap(InputStream inputStream) throws IOException {
pixmap = new Pixmap(new Gdx2DPixmap(inputStream, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888));
}
@Override
public int getWidth() {
return pixmap.getWidth();
}
@Override
public int getHeight() {
return pixmap.getHeight();
}
@Override
public void recycle() {
// FIXME this should be called at some point in time
pixmap.dispose();
}
@Override
public int[] getPixels() {
return null;
}
@Override
public void eraseColor(int color) {
}
@Override
public void uploadToTexture(boolean replace) {
Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(),
pixmap.getWidth(), pixmap.getHeight(), 0,
pixmap.getGLFormat(), pixmap.getGLType(),
pixmap.getPixels());
if (disposable) {
pixmap.dispose();
}
}
@Override
public boolean isValid() {
return true;
}
}

View File

@ -0,0 +1,78 @@
package org.oscim.ios.backend;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.TextureData;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.BitmapFont.Glyph;
public class IosCanvas implements Canvas {
IosBitmap bitmap;
static BitmapFont font = new BitmapFont();
public IosCanvas() {
// canvas comes with gdx pixmap
}
@Override
public void setBitmap(Bitmap bitmap) {
this.bitmap = (IosBitmap) bitmap;
this.bitmap.pixmap.setColor(0);
this.bitmap.pixmap.fill();
}
@Override
public void drawText(String string, float x, float y, Paint paint) {
if (bitmap == null) {
// log.debug("no bitmap set");
return;
}
// IosPaint p = (IosPaint) paint;
Pixmap pixmap = bitmap.pixmap;
TextureData td = font.getRegion().getTexture().getTextureData();
if (!td.isPrepared())
td.prepare();
Pixmap f = td.consumePixmap();
int adv = (int) x;
Glyph last = null;
int ch = (int) font.getCapHeight();
int h = (int) font.getLineHeight();
int yy = (int) (y - font.getLineHeight());
if (y < 0)
y = 0;
// pixmap.setColor(0xff0000ff);
// int w = (int) font.getBounds(string).width;
// pixmap.drawRectangle((int) x - 4, (int) y - 4, w + 8, h + 8);
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
Glyph g = font.getData().getGlyph(c);
if (g == null)
g = font.getData().getGlyph(' ');
if (i > 0)
adv += last.getKerning(c);
pixmap.drawPixmap(f, adv, //- g.xoffset,
yy - (g.height + g.yoffset) - (h - ch),
g.srcX, g.srcY,
g.width, g.height);
adv += g.width;
last = g;
}
}
@Override
public void drawBitmap(Bitmap bitmap, float x, float y) {
}
}

View File

@ -0,0 +1,9 @@
package org.oscim.ios.backend;
import org.oscim.backend.GL20;
import com.badlogic.gdx.backends.iosrobovm.IOSGLES20;
public class IosGLAdapter extends IOSGLES20 implements GL20 {
}

View File

@ -0,0 +1,56 @@
package org.oscim.ios.backend;
import java.io.IOException;
import java.io.InputStream;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
public class IosGraphics extends CanvasAdapter {
private static final IosGraphics INSTANCE = new IosGraphics();
public static CanvasAdapter get() {
return INSTANCE;
}
@Override
public Canvas getCanvas() {
return new IosCanvas();
}
@Override
public Paint getPaint() {
return new IosPaint();
}
@Override
public Bitmap getBitmap(int width, int height, int format) {
return new IosBitmap(width, height, format);
}
@Override
public Bitmap decodeBitmap(InputStream inputStream) {
try {
return new IosBitmap(inputStream);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Override
public Bitmap loadBitmapAsset(String fileName) {
return new IosBitmap(fileName);
// try {
// return createBitmap(fileName);
// } catch (IOException e) {
// e.printStackTrace();
// }
// return null;
}
}

View File

@ -0,0 +1,74 @@
package org.oscim.ios.backend;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Paint;
public class IosPaint implements Paint {
@Override
public int getColor() {
return 0;
}
@Override
public int getTextHeight(String text) {
return 0;
}
@Override
public int getTextWidth(String text) {
return 0;
}
@Override
public void setBitmapShader(Bitmap bitmap) {
}
@Override
public void setColor(int color) {
}
@Override
public void setDashPathEffect(float[] strokeDasharray) {
}
@Override
public void setStrokeCap(Cap cap) {
}
@Override
public void setStrokeWidth(float width) {
}
@Override
public void setStyle(Style style) {
}
@Override
public void setTextAlign(Align align) {
}
@Override
public void setTextSize(float textSize) {
}
@Override
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
}
@Override
public float measureText(String text) {
return IosCanvas.font.getBounds(text).width;
}
@Override
public float getFontHeight() {
return IosCanvas.font.getLineHeight();
}
@Override
public float getFontDescent() {
return IosCanvas.font.getDescent();
}
}