iOS: add POT textures test (#443)

This commit is contained in:
Longri 2017-11-12 07:36:04 +01:00 committed by Emux
parent df784f6f68
commit 9c3488e107
No known key found for this signature in database
GPG Key ID: 89C6921D7AF2BDD0
4 changed files with 124 additions and 10 deletions

View File

@ -29,6 +29,7 @@ dependencies {
implementation project(':vtm-gdx')
implementation project(':vtm-jts')
implementation project(':vtm-ios')
implementation project(':vtm-themes')
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
implementation "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
implementation "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"

View File

@ -38,11 +38,12 @@ public class ExampleLauncher extends IOSApplication.Delegate {
float scale = (float) (getIosVersion() >= 8 ? UIScreen.getMainScreen().getNativeScale() : UIScreen.getMainScreen().getScale());
CanvasAdapter.dpi *= scale;
IOSMapApp iosMapApp = new IOSMapApp();
// IOSLineTexTest iosMapApp = new IOSLineTexTest();
// IOSMapAppCluster iosMapApp = new IOSMapAppCluster();
// IOSMapApp iosMapApp = new IOSMapApp();
// IOSPathLayerTest iosMapApp = new IOSPathLayerTest();
IOSLineTexBucketTest iosMapApp = new IOSLineTexBucketTest();
// iOS needs POT textures for drawing lines with texture
Parameters.POT_TEXTURES = true;
iosMapApp.init();

View File

@ -0,0 +1,118 @@
/*
* Copyright 2017 Longri
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.ios.test;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.GLAdapter;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.Tag;
import org.oscim.core.TagSet;
import org.oscim.gdx.GdxAssets;
import org.oscim.gdx.GdxMap;
import org.oscim.ios.backend.IosGL;
import org.oscim.ios.backend.IosGraphics;
import org.oscim.layers.GenericLayer;
import org.oscim.renderer.BucketRenderer;
import org.oscim.renderer.GLViewport;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.bucket.LineTexBucket;
import org.oscim.renderer.bucket.TextureItem;
import org.oscim.theme.IRenderTheme;
import org.oscim.theme.ThemeLoader;
import org.oscim.theme.VtmThemes;
import org.oscim.theme.styles.LineStyle;
import org.oscim.theme.styles.RenderStyle;
import java.io.IOException;
public class IOSLineTexBucketTest extends GdxMap {
public static void init() {
// init globals
IosGraphics.init();
GdxAssets.init("assets/");
GLAdapter.init(new IosGL());
}
GeometryBuffer mLine = new GeometryBuffer(2, 1);
LineTest l = new LineTest();
@Override
public void createLayers() {
MapRenderer.setBackgroundColor(0xffffffff);
mMap.setMapPosition(0, 0, 1 << 4);
GeometryBuffer g = mLine;
g.startLine();
g.addPoint(-100, 0);
g.addPoint(100, 0);
addLines(l);
mMap.layers().add(new GenericLayer(mMap, l));
}
void addLines(LineTest l) {
GeometryBuffer g = mLine;
LineStyle lineStyle;
TextureItem tex = null;
try {
tex = new TextureItem(CanvasAdapter.getBitmapAsset("", "patterns/pike.png"));
tex.mipmap = true;
} catch (IOException e) {
e.printStackTrace();
}
IRenderTheme t = ThemeLoader.load(VtmThemes.DEFAULT);
TagSet tags = new TagSet();
tags.add(new Tag("highway", null));
tags.add(new Tag("oneway", "yes"));
RenderStyle[] ri = t.matchElement(GeometryBuffer.GeometryType.LINE, tags, 16);
lineStyle = (LineStyle) ri[0];
LineTexBucket lt = l.buckets.getLineTexBucket(20);
lt.line = lineStyle;
lt.addLine(g.translate(0, 10.5f));
}
class LineTest extends BucketRenderer {
public LineTest() {
mMapPosition.scale = 0;
}
@Override
public synchronized void update(GLViewport v) {
if (mMapPosition.scale == 0)
mMapPosition.copy(v.pos);
if (!isReady()) {
compile();
}
}
}
}

View File

@ -40,7 +40,7 @@ import org.oscim.utils.Utils;
import java.util.ArrayList;
import java.util.List;
public class IOSLineTexTest extends GdxMap {
public class IOSPathLayerTest extends GdxMap {
public static void init() {
// init globals
@ -91,12 +91,6 @@ public class IOSLineTexTest extends GdxMap {
List<GeoPoint> pts = new ArrayList<>();
for (double lon = -180; lon <= 180; lon += 2) {
//pts.add(new GeoPoint(lat, lon));
// double longitude = lon + (pos * 180);
// if (longitude < -180)
// longitude += 360;
// if (longitude > 180)
// longitude -= 360;
double longitude = lon;
double latitude = lat + (pos * 90);