fixing lwjgl stuff

This commit is contained in:
Hannes Janetzek 2013-06-24 04:59:19 +02:00
parent 5521583bd8
commit 30839efffd
24 changed files with 285 additions and 166 deletions

View File

@ -1,3 +1,4 @@
package org.oscim.android;
///* ///*
// * Copyright 2010, 2011, 2012 mapsforge.org // * Copyright 2010, 2011, 2012 mapsforge.org
// * Copyright 2013 Hannes Janetzek // * Copyright 2013 Hannes Janetzek

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="assets"/> <classpathentry kind="src" path="assets"/>
<classpathentry kind="src" path="gen"/> <classpathentry kind="src" path="gen"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/vtm"/> <classpathentry combineaccessrules="false" exported="true" kind="src" path="/vtm"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/vtm-gdx"/> <classpathentry combineaccessrules="false" exported="true" kind="src" path="/vtm-gdx"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="lib" path="/vtm-gdx/libs/gdx.jar" sourcepath="/vtm-gdx/libs/gdx-sources.jar"/> <classpathentry kind="output" path="bin/classes"/>
<classpathentry exported="true" kind="lib" path="libs/gdx-backend-android.jar" sourcepath="libs/gdx-backend-android-sources.jar"/> <classpathentry exported="true" kind="lib" path="libs/gdx-backend-android.jar" sourcepath="libs/gdx-backend-android-sources.jar"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry exported="true" kind="lib" path="/vtm-gdx/libs/gdx.jar" sourcepath="/vtm-gdx/libs/gdx-sources.jar"/>
</classpath> </classpath>

View File

@ -14,6 +14,7 @@ import android.os.Bundle;
import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.badlogic.gdx.backends.android.AndroidGL20; import com.badlogic.gdx.backends.android.AndroidGL20;
import com.badlogic.gdx.utils.SharedLibraryLoader;
public class MainActivity extends AndroidApplication { public class MainActivity extends AndroidApplication {
@ -34,6 +35,7 @@ public class MainActivity extends AndroidApplication {
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useGL20 = true; cfg.useGL20 = true;
new SharedLibraryLoader().load("vtm-jni");
initialize(new GdxMap(), cfg); initialize(new GdxMap(), cfg);
} }
} }

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="assets"/> <classpathentry kind="src" path="assets"/>
<classpathentry combineaccessrules="false" kind="src" path="/vtm-gdx"/> <classpathentry combineaccessrules="false" kind="src" path="/vtm-gdx"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="libs/gdx-backend-lwjgl.jar" sourcepath="libs/gdx-backend-lwjgl-sources.jar"/> <classpathentry kind="output" path="bin"/>
<classpathentry kind="lib" path="libs/gdx-backend-lwjgl-natives.jar"/> <classpathentry kind="lib" path="libs/gdx-backend-lwjgl-natives.jar"/>
<classpathentry kind="lib" path="libs/gdx-natives.jar"/> <classpathentry kind="lib" path="libs/gdx-backend-lwjgl.jar" sourcepath="libs/gdx-backend-lwjgl-sources.jar"/>
<classpathentry kind="lib" path="/vtm/libs/vtm-jni-natives.jar"/> <classpathentry kind="lib" path="libs/gdx-natives.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="lib" path="/vtm/libs/vtm-jni-natives.jar"/>
</classpath> </classpath>

View File

@ -7,6 +7,7 @@ import java.nio.IntBuffer;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import org.oscim.backend.Log;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
@ -27,6 +28,10 @@ public class AwtBitmap implements Bitmap {
AwtBitmap(InputStream inputStream) throws IOException { AwtBitmap(InputStream inputStream) throws IOException {
this.bitmap = ImageIO.read(inputStream); this.bitmap = ImageIO.read(inputStream);
this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight();
if(!this.bitmap.isAlphaPremultiplied())
this.bitmap.coerceData(true);
} }
@Override @Override
public int getWidth() { public int getWidth() {
@ -49,20 +54,23 @@ public class AwtBitmap implements Bitmap {
// TODO Auto-generated method stub // TODO Auto-generated method stub
} }
private static IntBuffer tmpBuffer = BufferUtils.newIntBuffer(256 * 256); private static IntBuffer tmpBuffer = BufferUtils.newIntBuffer(512 * 256);
private static int[] tmpPixel = new int[256 * 256]; private static int[] tmpPixel = new int[512 * 256];
@Override @Override
public int uploadToTexture(boolean replace) { public int uploadToTexture(boolean replace) {
int[] pixels; int[] pixels;
IntBuffer buffer; IntBuffer buffer;
if (width == 256 && height == 256){ if (width == 512 && height == 256){
pixels = tmpPixel; pixels = tmpPixel;
buffer = tmpBuffer; buffer = tmpBuffer;
buffer.clear(); buffer.clear();
Log.d("AwtBitmap", "default texture");
}else{ }else{
pixels = new int[width * height]; pixels = new int[width * height];
buffer = BufferUtils.newIntBuffer(width * height); buffer = BufferUtils.newIntBuffer(width * height);
Log.d("AwtBitmap", "create texture buffer " + width + "x" + height);
} }

View File

@ -1,9 +1,27 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013 Hannes Janetzek
*
* 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.awt; package org.oscim.awt;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.Color; import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.RenderingHints; import java.awt.RenderingHints;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas; import org.oscim.backend.canvas.Canvas;
@ -44,17 +62,48 @@ public class AwtCanvas implements Canvas {
} }
@Override @Override
public void drawText(String string, float x, float y, Paint stroke) { public void drawText(String text, float x, float y, Paint paint) {
AwtPaint p = (AwtPaint)stroke;
canvas.setFont(p.font); // if (paint.isTransparent()) {
canvas.setColor(p.color); // return;
// }
canvas.drawString(string, (int)x, (int)y); AwtPaint awtPaint = (AwtPaint)paint;
//AwtPaint awtPaint = AwtGraphicFactory.getAwtPaint(paint);
if (awtPaint.stroke == null) {
canvas.setColor(awtPaint.color);
canvas.setFont(awtPaint.font);
canvas.drawString(text, x, y);
} else {
setColorAndStroke(awtPaint);
TextLayout textLayout = new TextLayout(text, awtPaint.font, canvas.getFontRenderContext());
AffineTransform affineTransform = new AffineTransform();
affineTransform.translate(x, y);
canvas.draw(textLayout.getOutline(affineTransform));
}
} }
private void setColorAndStroke(AwtPaint awtPaint) {
canvas.setColor(awtPaint.color);
if (awtPaint.stroke != null) {
canvas.setStroke(awtPaint.stroke);
}
}
// @Override
// public void drawText(String string, float x, float y, Paint stroke) {
// AwtPaint p = (AwtPaint)stroke;
//
// canvas.setFont(p.font);
// canvas.setColor(p.color);
//
// canvas.drawString(string, (int)x, (int)y);
// }
@Override @Override
public void drawBitmap(Bitmap bitmap, float x, float y) { public void drawBitmap(Bitmap bitmap, float x, float y) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View File

@ -52,7 +52,7 @@ public class AwtGraphics extends CanvasAdapter {
static final Graphics2D canvas; static final Graphics2D canvas;
static { static {
image = new BufferedImage(64, 64, BufferedImage.TYPE_INT_ARGB); image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
canvas = image.createGraphics(); canvas = image.createGraphics();
canvas.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON ); canvas.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
//canvas.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); //canvas.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
@ -72,7 +72,8 @@ public class AwtGraphics extends CanvasAdapter {
} }
static synchronized float getTextWidth(FontMetrics fm, String text) { static synchronized float getTextWidth(FontMetrics fm, String text) {
return (float)fm.getStringBounds(text, canvas).getWidth(); //return (float)fm.getStringBounds(text, canvas).getWidth();
return fm.stringWidth(text);
} }
@Override @Override

View File

@ -1,22 +1,50 @@
/*
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
* Copyright 2013 Hannes Janetzek
*
* 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.awt; package org.oscim.awt;
import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Font; import java.awt.Font;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.awt.Stroke;
import java.awt.font.TextAttribute; import java.awt.font.TextAttribute;
import java.text.AttributedCharacterIterator.Attribute; import java.text.AttributedCharacterIterator.Attribute;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
//import org.oscim.graphics.Align;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
//import org.oscim.graphics.Cap;
//import org.oscim.graphics.FontFamily;
//import org.oscim.graphics.FontStyle;
import org.oscim.backend.canvas.Paint; import org.oscim.backend.canvas.Paint;
//import org.oscim.graphics.Style;
import com.badlogic.gdx.Gdx;
public class AwtPaint implements Paint { public class AwtPaint implements Paint {
private static int getCap(Cap cap) {
switch (cap) {
case BUTT:
return BasicStroke.CAP_BUTT;
case ROUND:
return BasicStroke.CAP_ROUND;
case SQUARE:
return BasicStroke.CAP_SQUARE;
}
throw new IllegalArgumentException("unknown cap: " + cap);
}
static final Font defaultFont; static final Font defaultFont;
static { static {
Map<Attribute, Object> textAttributes = new HashMap<Attribute, Object>(); Map<Attribute, Object> textAttributes = new HashMap<Attribute, Object>();
@ -25,13 +53,16 @@ public class AwtPaint implements Paint {
textAttributes.put(TextAttribute.SIZE, 13); textAttributes.put(TextAttribute.SIZE, 13);
defaultFont = Font.getFont(textAttributes); defaultFont = Font.getFont(textAttributes);
} }
Font font = defaultFont; //new Font("Default", Font.PLAIN, 13); Font font = defaultFont; // new Font("Default", Font.PLAIN, 13);
Stroke stroke;
FontMetrics fm; FontMetrics fm;
Color color = new Color(0.1f,0.1f,0.1f,1); Color color = new Color(0.1f, 0.1f, 0.1f, 1);
private int cap;
private float strokeWidth;
private Align mAlign;
@Override @Override
public int getColor() { public int getColor() {
@ -58,13 +89,11 @@ public class AwtPaint implements Paint {
} }
@Override @Override
public void setColor(int color) { public void setColor(int c) {
this.color = new Color( color = new Color(((c >> 16) & 0xff) / 255f,
((color >> 16) & 0xff)/255f, ((c >> 8) & 0xff) / 255f,
((color >> 8) & 0xff)/255f, ((c >> 0) & 0xff) / 255f,
((color >> 0) & 0xff)/255f, ((c >> 24) & 0xff) / 255f);
((color >> 24) & 0xff)/255f
);
} }
@Override @Override
@ -75,14 +104,17 @@ public class AwtPaint implements Paint {
@Override @Override
public void setStrokeCap(Cap cap) { public void setStrokeCap(Cap cap) {
// TODO Auto-generated method stub this.cap = getCap(cap);
createStroke();
} }
@Override @Override
public void setStrokeWidth(float width) { public void setStrokeWidth(float width) {
//int size = font.getSize(); strokeWidth = width;
//font = font.deriveFont(size + width * 4); createStroke();
// int size = font.getSize();
// font = font.deriveFont(size + width * 4);
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -96,8 +128,7 @@ public class AwtPaint implements Paint {
@Override @Override
public void setTextAlign(Align align) { public void setTextAlign(Align align) {
// TODO Auto-generated method stub mAlign = align;
} }
@Override @Override
@ -116,12 +147,13 @@ public class AwtPaint implements Paint {
public float measureText(String text) { public float measureText(String text) {
if (fm == null) if (fm == null)
fm = AwtGraphics.getFontMetrics(this.font); fm = AwtGraphics.getFontMetrics(this.font);
float w = AwtGraphics.getTextWidth(fm, text); float w = AwtGraphics.getTextWidth(fm, text);
//Gdx.app.log("text width:", text + " " + w); //Gdx.app.log("text width:", text + " " + w);
return w; return w;
//return fm.getStringBounds(text, A).getWidth(); // return fm.getStringBounds(text, A).getWidth();
//return AwtGraphics.getTextWidth(fm, text); // return AwtGraphics.getTextWidth(fm, text);
//return fm.stringWidth(text); // return fm.stringWidth(text);
} }
@Override @Override
@ -131,7 +163,6 @@ public class AwtPaint implements Paint {
float height = fm.getHeight(); float height = fm.getHeight();
//Gdx.app.log("text height", " " + height);
return height; return height;
} }
@ -141,9 +172,14 @@ public class AwtPaint implements Paint {
fm = AwtGraphics.getFontMetrics(this.font); fm = AwtGraphics.getFontMetrics(this.font);
float desc = fm.getDescent(); float desc = fm.getDescent();
//Gdx.app.log("text descent", " " + desc);
return desc; return desc;
} }
private void createStroke() {
if (strokeWidth <= 0) {
return;
}
stroke = new BasicStroke(strokeWidth, cap, BasicStroke.JOIN_ROUND, 0, null, 0);
}
} }

View File

@ -4,9 +4,11 @@ import org.oscim.awt.AwtGraphics;
import org.oscim.backend.CanvasAdapter; import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.GLAdapter; import org.oscim.backend.GLAdapter;
import org.oscim.core.Tile; import org.oscim.core.Tile;
import org.oscim.renderer.GLRenderer;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.badlogic.gdx.utils.SharedLibraryLoader;
public class Main { public class Main {
@ -17,12 +19,16 @@ public class Main {
cfg.width = 1280; cfg.width = 1280;
cfg.height = 800; cfg.height = 800;
cfg.stencil= 8; cfg.stencil= 8;
cfg.foregroundFPS = 20;
//cfg.samples = 4; //cfg.samples = 4;
// set our globals // set our globals
CanvasAdapter.g = AwtGraphics.INSTANCE; CanvasAdapter.g = AwtGraphics.INSTANCE;
GLAdapter.INSTANCE = new GdxGLAdapter(); GLAdapter.INSTANCE = new GdxGLAdapter();
Tile.SIZE = 256; Tile.SIZE = 256;
GLRenderer.alwaysAllocBuffer = true;
new SharedLibraryLoader().load("vtm-jni");
new LwjglApplication(new GdxMap(), cfg); new LwjglApplication(new GdxMap(), cfg);
} }

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" kind="src" path="/vtm-gdx"/> <classpathentry combineaccessrules="false" kind="src" path="/vtm-gdx"/>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/> <classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/vtm-gdx/libs/gdx.jar" sourcepath="/vtm-gdx/libs/gdx-sources.jar"/> <classpathentry combineaccessrules="false" kind="src" path="/vtm"/>
<classpathentry kind="lib" path="/vtm-gdx/libs/gdx-sources.jar"/> <classpathentry kind="output" path="war/WEB-INF/classes"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/gdx-backend-gwt.jar" sourcepath="war/WEB-INF/lib/gdx-backend-gwt-sources.jar"/> <classpathentry kind="lib" path="war/WEB-INF/lib/gdx-backend-gwt-sources.jar"/>
<classpathentry kind="lib" path="war/WEB-INF/lib/gdx-backend-gwt-sources.jar"/> <classpathentry kind="lib" path="war/WEB-INF/lib/gdx-backend-gwt.jar" sourcepath="war/WEB-INF/lib/gdx-backend-gwt-sources.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/vtm"/> <classpathentry kind="lib" path="/vtm-gdx/libs/gdx-sources.jar"/>
<classpathentry kind="output" path="war/WEB-INF/classes"/> <classpathentry kind="lib" path="/vtm-gdx/libs/gdx.jar" sourcepath="/vtm-gdx/libs/gdx-sources.jar"/>
</classpath> </classpath>

View File

@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://google-web-toolkit.googlecode.com/svn/trunk/distro-source/core/src/gwt-module.dtd"> <module>
<module> <entry-point class="org.oscim.gdx.client.GwtLauncher"/>
<inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' /> <set-configuration-property name="gdx.assetpath" value="../vtm/assets"/>
<inherits name='GdxMap' /> <inherits name="GdxMap"/>
<entry-point class='org.oscim.gdx.client.GwtLauncher' /> <inherits name="com.badlogic.gdx.backends.gdx_backends_gwt"/>
<set-configuration-property name="gdx.assetpath" value="../vtm/assets" /> </module>
</module>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<classpath> <classpath>
<classpathentry kind="src" path="src"/> <classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="libs/gdx.jar" sourcepath="libs/gdx-sources.jar"/> <classpathentry combineaccessrules="false" exported="true" kind="src" path="/vtm"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/vtm"/> <classpathentry kind="output" path="bin"/>
<classpathentry kind="output" path="bin"/> <classpathentry exported="true" kind="lib" path="libs/gdx.jar" sourcepath="libs/gdx-sources.jar"/>
</classpath> </classpath>

View File

@ -1,7 +1,6 @@
package org.oscim.gdx; package org.oscim.gdx;
import org.oscim.backend.AssetAdapter; import org.oscim.backend.AssetAdapter;
import org.oscim.backend.GL20;
import org.oscim.backend.Log; import org.oscim.backend.Log;
import org.oscim.backend.input.MotionEvent; import org.oscim.backend.input.MotionEvent;
import org.oscim.layers.tile.vector.MapTileLayer; import org.oscim.layers.tile.vector.MapTileLayer;
@ -9,7 +8,7 @@ import org.oscim.renderer.GLRenderer;
import org.oscim.renderer.GLState; import org.oscim.renderer.GLState;
import org.oscim.theme.InternalRenderTheme; import org.oscim.theme.InternalRenderTheme;
import org.oscim.tilesource.TileSource; import org.oscim.tilesource.TileSource;
import org.oscim.tilesource.oscimap4.OSciMap4TileSource; import org.oscim.tilesource.oscimap2.OSciMap2TileSource;
import org.oscim.view.MapRenderCallback; import org.oscim.view.MapRenderCallback;
import org.oscim.view.MapView; import org.oscim.view.MapView;
import org.oscim.view.MapViewPosition; import org.oscim.view.MapViewPosition;
@ -18,11 +17,6 @@ import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.utils.SharedLibraryLoader;
public class GdxMap implements ApplicationListener, MapRenderCallback { public class GdxMap implements ApplicationListener, MapRenderCallback {
@ -30,22 +24,20 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
private final GLRenderer mMapRenderer; private final GLRenderer mMapRenderer;
public GdxMap() { public GdxMap() {
new SharedLibraryLoader().load("vtm-jni");
AssetAdapter.g = new GdxAssetAdapter(); AssetAdapter.g = new GdxAssetAdapter();
mMapView = new MapView(this); mMapView = new MapView(this);
mMapRenderer = new GLRenderer(mMapView); mMapRenderer = new GLRenderer(mMapView);
} }
Stage ui; // Stage ui;
Label fps; // Label fps;
BitmapFont font; // BitmapFont font;
@Override @Override
public void create() { public void create() {
// Gdx.graphics.setContinuousRendering(false); Gdx.graphics.setContinuousRendering(false);
if (Log.logger == null) if (Log.logger == null)
Log.logger = new GdxLog(); Log.logger = new GdxLog();
@ -58,17 +50,17 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
mWidth = w; mWidth = w;
mHeight = h; mHeight = h;
// TileSource tileSource = new OSciMap2TileSource(); TileSource tileSource = new OSciMap2TileSource();
// tileSource.setOption("url", tileSource.setOption("url",
// "http://city.informatik.uni-bremen.de/osci/map-live"); "http://city.informatik.uni-bremen.de/osci/map-live");
TileSource tileSource = new OSciMap4TileSource(); //TileSource tileSource = new OSciMap4TileSource();
tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing"); //tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing");
MapTileLayer l = mMapView.setBaseMap(tileSource); MapTileLayer l = mMapView.setBaseMap(tileSource);
l.setRenderTheme(InternalRenderTheme.DEFAULT); l.setRenderTheme(InternalRenderTheme.DEFAULT);
// mMapView.getLayerManager().add(new GenericOverlay(mMapView, new //mMapView.getLayerManager().add(new GenericOverlay(mMapView, new
// GridRenderLayer(mMapView))); // GridRenderLayer(mMapView)));
mMapView.getMapViewPosition().setViewport(w, h); mMapView.getMapViewPosition().setViewport(w, h);
@ -77,21 +69,21 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
Gdx.input.setInputProcessor(new TouchHandler()); Gdx.input.setInputProcessor(new TouchHandler());
ui = new Stage(w, h, false); // ui = new Stage(w, h, false);
// font = new BitmapFont(false);
font = new BitmapFont(false); // fps = new Label("fps: 0", new Label.LabelStyle(font, Color.WHITE));
// fps.setPosition(10, 30);
fps = new Label("fps: 0", new Label.LabelStyle(font, Color.WHITE)); // fps.setColor(0, 1, 0, 1);
fps.setPosition(10, 30); // ui.addActor(fps);
fps.setColor(0, 1, 0, 1);
ui.addActor(fps);
} }
@Override @Override
public void dispose() { public void dispose() {
} }
private int fpsCnt = 0; private int fpsCnt = 0;
@Override @Override
public void render() { public void render() {
// GLState.enableVertexArrays(-1, -1); // GLState.enableVertexArrays(-1, -1);
@ -101,14 +93,14 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
mMapRenderer.onDrawFrame(); mMapRenderer.onDrawFrame();
// Gdx.gl20.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0); // Gdx.gl20.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
// Gdx.gl20.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0); // Gdx.gl20.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
int f = Gdx.graphics.getFramesPerSecond(); // int f = Gdx.graphics.getFramesPerSecond();
if (f != fpsCnt){ // if (f != fpsCnt) {
Log.d("fps", ">" +f); // Log.d("fps", ">" + f);
fpsCnt = f; // fpsCnt = f;
} // }
// fps.setText("fps: " + Gdx.graphics.getFramesPerSecond()); // fps.setText("fps: " + Gdx.graphics.getFramesPerSecond());
// ui.draw(); // ui.draw();
} }
@ -137,16 +129,17 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
* also render frame FIXME (does nothing atm) * also render frame FIXME (does nothing atm)
*/ */
void redrawMapInternal(boolean forceRedraw) { void redrawMapInternal(boolean forceRedraw) {
GLState.blend(false);
if (forceRedraw && !mClearMap) GLState.test(false, false);
Gdx.graphics.requestRendering(); //if (forceRedraw && !mClearMap)
// Gdx.graphics.requestRendering();
mMapView.updateLayers(); mMapView.updateLayers();
if (mClearMap) { //if (mClearMap) {
Gdx.graphics.requestRendering(); Gdx.graphics.requestRendering();
mClearMap = false; mClearMap = false;
} //}
} }
private boolean mClearMap; private boolean mClearMap;
@ -349,7 +342,7 @@ public class GdxMap implements ApplicationListener, MapRenderCallback {
} }
if (changed) if (changed)
updateMap(false); updateMap(true);
return true; return true;
} }

View File

@ -600,10 +600,17 @@ class TextRenderLayer extends BasicRenderLayer {
return true; return true;
} }
long lastDraw = 0;
@Override @Override
public synchronized void update(MapPosition pos, boolean changed, public synchronized void update(MapPosition pos, boolean changed,
Matrices matrices) { Matrices matrices) {
if (System.currentTimeMillis() - lastDraw > 1000){
updateLabels();
lastDraw = System.currentTimeMillis();
}
if (mNextLayer.ready) { if (mNextLayer.ready) {
// exchange current with next layers // exchange current with next layers
TextureLayers tmp = mCurLayer; TextureLayers tmp = mCurLayer;
@ -626,6 +633,7 @@ class TextRenderLayer extends BasicRenderLayer {
this.newData = true; this.newData = true;
} }
//if (!mHolding) //if (!mHolding)
// postLabelTask((mLastRun + MAX_RELABEL_DELAY) - System.currentTimeMillis()); // postLabelTask((mLastRun + MAX_RELABEL_DELAY) - System.currentTimeMillis());
} }

View File

@ -66,7 +66,8 @@ public class TileRenderer {
mProjMatrix.setValue(14, 0); mProjMatrix.setValue(14, 0);
mProjMatrix.multiplyRhs(m.view); mProjMatrix.multiplyRhs(m.view);
GL.glDepthMask(true);
//GL.glDepthMask(true);
GL.glClear(GL20.GL_DEPTH_BUFFER_BIT); GL.glClear(GL20.GL_DEPTH_BUFFER_BIT);
GL.glDepthFunc(GL20.GL_LESS); GL.glDepthFunc(GL20.GL_LESS);

View File

@ -71,7 +71,7 @@ public class GridRenderLayer extends BasicRenderLayer {
mTextLayer = layers.addTextLayer(new TextLayer()); mTextLayer = layers.addTextLayer(new TextLayer());
mLineLayer = layers.addLineLayer(0, mLineLayer = layers.addLineLayer(0,
new Line(Color.BLUE, 1.5f, Cap.BUTT)); new Line(Color.BLUE, 1.5f, Cap.BUTT));
} }
private void addLabels(int x, int y, int z) { private void addLabels(int x, int y, int z) {
@ -83,11 +83,14 @@ public class GridRenderLayer extends BasicRenderLayer {
for (int yy = -2; yy < 2; yy++) { for (int yy = -2; yy < 2; yy++) {
for (int xx = -2; xx < 2; xx++) { for (int xx = -2; xx < 2; xx++) {
String label = String.format( // String label = String.format(
Locale.ROOT, TILE_FORMAT, // Locale.ROOT, TILE_FORMAT,
Integer.valueOf(x + xx), // Integer.valueOf(x + xx),
Integer.valueOf(y + yy), // Integer.valueOf(y + yy),
Integer.valueOf(z)); // Integer.valueOf(z));
String label = Integer.valueOf(x + xx) + "/" +
Integer.valueOf(y + yy) + "/" +
Integer.valueOf(z);
TextItem ti = TextItem.pool.get(); TextItem ti = TextItem.pool.get();
ti.set(s * xx + s / 2, s * yy + s / 2, label, mText); ti.set(s * xx + s / 2, s * yy + s / 2, label, mText);

View File

@ -88,15 +88,16 @@ public final class LineRenderer {
GL20.GL_NEAREST, GL20.GL_NEAREST, GL20.GL_NEAREST, GL20.GL_NEAREST,
GL20.GL_MIRRORED_REPEAT, GL20.GL_MIRRORED_REPEAT); GL20.GL_MIRRORED_REPEAT, GL20.GL_MIRRORED_REPEAT);
Log.d(TAG, "Line Texture >>>>>>>>> " + mTexID);
return true; return true;
} }
public static void beginLines() { public static void beginLines() {
GL.glBindTexture(GL20.GL_TEXTURE_2D, mTexID); //GL.glBindTexture(GL20.GL_TEXTURE_2D, mTexID);
} }
public static void endLines() { public static void endLines() {
GL.glBindTexture(GL20.GL_TEXTURE_2D, 0); //GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
} }
public static Layer draw(Layers layers, Layer curLayer, MapPosition pos, public static Layer draw(Layers layers, Layer curLayer, MapPosition pos,
@ -280,8 +281,10 @@ public final class LineRenderer {
//+ " len = abs(v_st.s);" //+ " len = abs(v_st.s);"
//+ " else" //+ " else"
//+ " len = texture2D(tex, v_st).a;" //+ " len = texture2D(tex, v_st).a;"
//+ " len = u_mode * length(v_st);"
// this avoids branching, need to check performance // this avoids branching, need to check performance
+ " float len = max((1.0 - u_mode) * abs(v_st.s), u_mode * texture2D(tex, v_st).a);" //+ " float len = max((1.0 - u_mode) * abs(v_st.s), u_mode * texture2D(tex, v_st).a);"
+ " float len = max((1.0 - u_mode) * abs(v_st.s), u_mode * length(v_st));"
// interpolate alpha between: 0.0 < 1.0 - len < u_wscale // interpolate alpha between: 0.0 < 1.0 - len < u_wscale
// where wscale is 'filter width' / 'line width' and 0 <= len <= sqrt(2) // where wscale is 'filter width' / 'line width' and 0 <= len <= sqrt(2)
//+ " gl_FragColor = u_color * smoothstep(0.0, u_wscale, 1.0 - len);" //+ " gl_FragColor = u_color * smoothstep(0.0, u_wscale, 1.0 - len);"
@ -304,8 +307,8 @@ public final class LineRenderer {
+ " len = abs(v_st.s);" + " len = abs(v_st.s);"
+ " fuzz = fwidth(v_st.s);" + " fuzz = fwidth(v_st.s);"
+ " } else {" + " } else {"
+ " len = texture2D(tex, v_st).a;" //+ " len = texture2D(tex, v_st).a;"
//+ " len = length(v_st);" + " len = length(v_st);"
+ " vec2 st_width = fwidth(v_st);" + " vec2 st_width = fwidth(v_st);"
+ " fuzz = max(st_width.s, st_width.t);" + " fuzz = max(st_width.s, st_width.t);"
+ " }" + " }"

View File

@ -129,9 +129,9 @@ public final class TextLayer extends TextureLayer {
yy = y + height - it.text.fontDescent; // - mFontPadY; yy = y + height - it.text.fontDescent; // - mFontPadY;
if (it.text.stroke != null) if (it.text.stroke != null)
mCanvas.drawText(it.string, x + it.width / 2, yy, it.text.stroke); mCanvas.drawText(it.string, x, yy, it.text.stroke);
mCanvas.drawText(it.string, x + it.width / 2, yy, it.text.paint); mCanvas.drawText(it.string, x, yy, it.text.paint);
// FIXME !!! // FIXME !!!
if (width > TEXTURE_WIDTH) if (width > TEXTURE_WIDTH)

View File

@ -81,6 +81,7 @@ public class TextureItem extends Inlist<TextureItem> {
*/ */
public synchronized static TextureItem get(boolean initBitmap) { public synchronized static TextureItem get(boolean initBitmap) {
TextureItem ti = pool.get(); TextureItem ti = pool.get();
Log.d(TAG, "get texture item " + ti.id);
if (initBitmap) { if (initBitmap) {
ti.bitmap = getBitmap(); ti.bitmap = getBitmap();
ti.bitmap.eraseColor(Color.TRANSPARENT); ti.bitmap.eraseColor(Color.TRANSPARENT);
@ -171,8 +172,11 @@ public class TextureItem extends Inlist<TextureItem> {
int[] tmp = new int[size]; int[] tmp = new int[size];
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
tmp[i] = mTextures.get(i).intValue(); tmp[i] = mTextures.get(i).intValue();
mTextures.clear(); mTextures.clear();
GlUtils.glDeleteTextures(size, tmp); GlUtils.glDeleteTextures(size, tmp);
mTexCnt -= size;
} }
if (to.id < 0) { if (to.id < 0) {
@ -180,9 +184,9 @@ public class TextureItem extends Inlist<TextureItem> {
int[] textureIds = GlUtils.glGenTextures(1); int[] textureIds = GlUtils.glGenTextures(1);
to.id = textureIds[0]; to.id = textureIds[0];
initTexture(to.id); initTexture(to.id);
if (TextureRenderer.debug) //if (TextureRenderer.debug)
Log.d(TAG, pool.getCount() + " " + pool.getFill() Log.d(TAG, "poolCnt:" + pool.getCount() + " poolFill:" + pool.getFill()
+ " " + mTexCnt + " new texture " + to.id); + " texCnt:" + mTexCnt + " new texture " + to.id);
} }
uploadTexture(to, to.bitmap, mBitmapFormat, mBitmapType, uploadTexture(to, to.bitmap, mBitmapFormat, mBitmapType,
@ -203,8 +207,9 @@ public class TextureItem extends Inlist<TextureItem> {
Log.d(TAG, "no texture!"); Log.d(TAG, "no texture!");
return; return;
} }
GL.glBindTexture(GL20.GL_TEXTURE_2D, to.id);
GL.glBindTexture(GL20.GL_TEXTURE_2D, to.id);
Log.d(TAG, "upload " + to.id);
if (to.ownBitmap) { if (to.ownBitmap) {
bitmap.uploadToTexture(false); bitmap.uploadToTexture(false);
//GLUtils.texImage2D(GL20.GL_TEXTURE_2D, 0, bitmap, 0); //GLUtils.texImage2D(GL20.GL_TEXTURE_2D, 0, bitmap, 0);

View File

@ -82,6 +82,7 @@ public final class TextureRenderer {
for (TextureItem ti = tl.textures; ti != null; ti = ti.next) { for (TextureItem ti = tl.textures; ti != null; ti = ti.next) {
GL.glBindTexture(GL20.GL_TEXTURE_2D, ti.id); GL.glBindTexture(GL20.GL_TEXTURE_2D, ti.id);
int maxVertices = GLRenderer.maxQuads * INDICES_PER_SPRITE; int maxVertices = GLRenderer.maxQuads * INDICES_PER_SPRITE;
GL.glUniform2f(hTextureSize, GL.glUniform2f(hTextureSize,
@ -110,6 +111,8 @@ public final class TextureRenderer {
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0); GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
//GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
return layer.next; return layer.next;
} }

View File

@ -14,9 +14,6 @@
*/ */
package org.oscim.theme.renderinstruction; package org.oscim.theme.renderinstruction;
import java.util.Locale;
import java.util.regex.Pattern;
import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint.Cap; import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.theme.IRenderCallback; import org.oscim.theme.IRenderCallback;
@ -27,7 +24,7 @@ import org.xml.sax.Attributes;
* Represents a polyline on the map. * Represents a polyline on the map.
*/ */
public final class Line extends RenderInstruction { public final class Line extends RenderInstruction {
private static final Pattern SPLIT_PATTERN = Pattern.compile(","); //private static final Pattern SPLIT_PATTERN = Pattern.compile(",");
/** /**
* @param line * @param line
@ -92,7 +89,7 @@ public final class Line extends RenderInstruction {
} else if ("width".equals(name)) { } else if ("width".equals(name)) {
width = Float.parseFloat(value); width = Float.parseFloat(value);
} else if ("cap".equals(name)) { } else if ("cap".equals(name)) {
cap = Cap.valueOf(value.toUpperCase(Locale.ENGLISH)); cap = Cap.valueOf(value.toUpperCase());
} else if ("fix".equals(name)) { } else if ("fix".equals(name)) {
fixed = Boolean.parseBoolean(value); fixed = Boolean.parseBoolean(value);
} else if ("stipple".equals(name)) { } else if ("stipple".equals(name)) {
@ -136,14 +133,14 @@ public final class Line extends RenderInstruction {
} }
} }
static float[] parseFloatArray(String dashString) { // static float[] parseFloatArray(String dashString) {
String[] dashEntries = SPLIT_PATTERN.split(dashString); // String[] dashEntries = SPLIT_PATTERN.split(dashString);
float[] dashIntervals = new float[dashEntries.length]; // float[] dashIntervals = new float[dashEntries.length];
for (int i = 0; i < dashEntries.length; ++i) { // for (int i = 0; i < dashEntries.length; ++i) {
dashIntervals[i] = Float.parseFloat(dashEntries[i]); // dashIntervals[i] = Float.parseFloat(dashEntries[i]);
} // }
return dashIntervals; // return dashIntervals;
} // }
private final int level; private final int level;

View File

@ -63,9 +63,9 @@ public final class Text extends RenderInstruction {
else if ("k".equals(name)) { else if ("k".equals(name)) {
textKey = value.intern(); textKey = value.intern();
} else if ("font-family".equals(name)) { } else if ("font-family".equals(name)) {
fontFamily = FontFamily.valueOf(value.toUpperCase(Locale.ENGLISH)); fontFamily = FontFamily.valueOf(value.toUpperCase());
} else if ("font-style".equals(name)) { } else if ("font-style".equals(name)) {
fontStyle = FontStyle.valueOf(value.toUpperCase(Locale.ENGLISH)); fontStyle = FontStyle.valueOf(value.toUpperCase());
} else if ("font-size".equals(name)) { } else if ("font-size".equals(name)) {
fontSize = Float.parseFloat(value); fontSize = Float.parseFloat(value);
} else if ("fill".equals(name)) { } else if ("fill".equals(name)) {

View File

@ -18,10 +18,8 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Stack; import java.util.Stack;
import java.util.regex.Pattern;
import org.oscim.core.Tag; import org.oscim.core.Tag;
import org.oscim.theme.RenderThemeHandler; import org.oscim.theme.RenderThemeHandler;
@ -31,7 +29,7 @@ import org.xml.sax.Attributes;
public abstract class Rule { public abstract class Rule {
private static final Map<List<String>, AttributeMatcher> MATCHERS_CACHE_KEY = new HashMap<List<String>, AttributeMatcher>(); private static final Map<List<String>, AttributeMatcher> MATCHERS_CACHE_KEY = new HashMap<List<String>, AttributeMatcher>();
private static final Map<List<String>, AttributeMatcher> MATCHERS_CACHE_VALUE = new HashMap<List<String>, AttributeMatcher>(); private static final Map<List<String>, AttributeMatcher> MATCHERS_CACHE_VALUE = new HashMap<List<String>, AttributeMatcher>();
private static final Pattern SPLIT_PATTERN = Pattern.compile("\\|"); //private static final Pattern SPLIT_PATTERN = Pattern.compile("\\|");
private static final String STRING_NEGATION = "~"; private static final String STRING_NEGATION = "~";
private static final String STRING_EXCLUSIVE = "-"; private static final String STRING_EXCLUSIVE = "-";
private static final String STRING_WILDCARD = "*"; private static final String STRING_WILDCARD = "*";
@ -52,7 +50,8 @@ public abstract class Rule {
if (values == null) { if (values == null) {
valueMatcher = AnyMatcher.getInstance(); valueMatcher = AnyMatcher.getInstance();
} else { } else {
valueList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN.split(values))); //valueList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN.split(values)));
valueList = new ArrayList<String>(Arrays.asList(values.split("\\|")));
if (valueList.remove(STRING_NEGATION)) if (valueList.remove(STRING_NEGATION))
negativeRule = true; negativeRule = true;
else if (valueList.remove(STRING_EXCLUSIVE)) else if (valueList.remove(STRING_EXCLUSIVE))
@ -69,7 +68,8 @@ public abstract class Rule {
} }
keyMatcher = AnyMatcher.getInstance(); keyMatcher = AnyMatcher.getInstance();
} else { } else {
keyList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN.split(keys))); //keyList = new ArrayList<String>(Arrays.asList(SPLIT_PATTERN.split(keys)));
keyList = new ArrayList<String>(Arrays.asList(keys.split("\\|")));
keyMatcher = getKeyMatcher(keyList); keyMatcher = getKeyMatcher(keyList);
if ((keyMatcher instanceof AnyMatcher) && (negativeRule || exclusionRule)) { if ((keyMatcher instanceof AnyMatcher) && (negativeRule || exclusionRule)) {
@ -150,7 +150,7 @@ public abstract class Rule {
String value = attributes.getValue(i); String value = attributes.getValue(i);
if ("e".equals(name)) { if ("e".equals(name)) {
String val = value.toUpperCase(Locale.ENGLISH); String val = value.toUpperCase();
if ("WAY".equals(val)) if ("WAY".equals(val))
element = Element.WAY; element = Element.WAY;
else if ("NODE".equals(val)) else if ("NODE".equals(val))
@ -160,7 +160,7 @@ public abstract class Rule {
} else if ("v".equals(name)) { } else if ("v".equals(name)) {
values = value; values = value;
} else if ("closed".equals(name)) { } else if ("closed".equals(name)) {
String val = value.toUpperCase(Locale.ENGLISH); String val = value.toUpperCase();
if ("YES".equals(val)) if ("YES".equals(val))
closed = Closed.YES; closed = Closed.YES;
else if ("NO".equals(val)) else if ("NO".equals(val))

View File

@ -326,6 +326,8 @@ public class GlUtils {
public static int[] glGenBuffers(int num) { public static int[] glGenBuffers(int num) {
IntBuffer buf = GLRenderer.getIntBuffer(num); IntBuffer buf = GLRenderer.getIntBuffer(num);
buf.position(0);
buf.limit(num);
GL.glGenBuffers(num, buf); GL.glGenBuffers(num, buf);
int[] ret = new int[num]; int[] ret = new int[num];
buf.position(0); buf.position(0);
@ -343,6 +345,8 @@ public class GlUtils {
public static int[] glGenTextures(int num) { public static int[] glGenTextures(int num) {
IntBuffer buf = GLRenderer.getIntBuffer(num); IntBuffer buf = GLRenderer.getIntBuffer(num);
buf.position(0);
buf.limit(num);
GL.glGenTextures(num, buf); GL.glGenTextures(num, buf);
int[] ret = new int[num]; int[] ret = new int[num];
buf.position(0); buf.position(0);