consistent formatting
This commit is contained in:
parent
57dfd91378
commit
c720cf22aa
@ -23,9 +23,11 @@ import android.content.Context;
|
||||
|
||||
public class AndroidAssetAdapter extends AssetAdapter {
|
||||
Context mContext;
|
||||
|
||||
public AndroidAssetAdapter(Context ctx) {
|
||||
mContext = ctx;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream openFileAsStream(String fileName) {
|
||||
try {
|
||||
|
@ -16,7 +16,6 @@ package org.oscim.android;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class AndroidLog implements org.oscim.backend.Log.Logger {
|
||||
|
||||
@Override
|
||||
|
@ -47,7 +47,6 @@ public class GLView extends GLSurfaceView {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public GLView(Context context, Map map) {
|
||||
super(context);
|
||||
setEGLConfigChooser(new GlConfigChooser());
|
||||
|
@ -41,6 +41,7 @@ public abstract class MapActivity extends Activity {
|
||||
private static final String KEY_MAP_SCALE = "map_scale";
|
||||
|
||||
private static final String PREFERENCES_FILE = "MapActivity";
|
||||
|
||||
//private static final String KEY_THEME = "Theme";
|
||||
|
||||
private static boolean containsViewport(SharedPreferences sharedPreferences) {
|
||||
@ -108,7 +109,6 @@ public abstract class MapActivity extends Activity {
|
||||
int longitudeE6 = sharedPreferences.getInt(KEY_LONGITUDE, 0);
|
||||
float scale = sharedPreferences.getFloat(KEY_MAP_SCALE, 1);
|
||||
|
||||
|
||||
MapPosition mapPosition = new MapPosition();
|
||||
mapPosition.setPosition(latitudeE6 / 1E6, longitudeE6 / 1E6);
|
||||
mapPosition.setScale(scale);
|
||||
|
@ -1,4 +1,5 @@
|
||||
package org.oscim.android;
|
||||
|
||||
///*
|
||||
// * Copyright 2010, 2011, 2012 mapsforge.org
|
||||
// * Copyright 2013 Hannes Janetzek
|
||||
|
@ -51,7 +51,6 @@ public class MapView extends RelativeLayout {
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
|
||||
|
||||
private final Map mMap;
|
||||
|
||||
final GLView mGLView;
|
||||
@ -203,7 +202,6 @@ public class MapView extends RelativeLayout {
|
||||
//mMap.destroy();
|
||||
}
|
||||
|
||||
|
||||
void onPause() {
|
||||
mPausing = true;
|
||||
|
||||
@ -250,7 +248,6 @@ public class MapView extends RelativeLayout {
|
||||
mMap.getViewport().setViewport(width, height);
|
||||
}
|
||||
|
||||
|
||||
public void enableRotation(boolean enable) {
|
||||
mRotationEnabled = enable;
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
package org.oscim.android;
|
||||
|
||||
///*
|
||||
// * Copyright 2010, 2011, 2012 mapsforge.org
|
||||
// *
|
||||
|
@ -35,6 +35,7 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
mBitmap = android.graphics.Bitmap
|
||||
.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
AndroidBitmap(android.graphics.Bitmap bitmap) {
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public class AndroidCanvas implements Canvas {
|
||||
public AndroidCanvas() {
|
||||
this.canvas = new android.graphics.Canvas();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
|
||||
@ -20,6 +21,7 @@ public class AndroidCanvas implements Canvas {
|
||||
this.canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
this.canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
|
||||
|
@ -100,8 +100,8 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
|
||||
}
|
||||
|
||||
android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(
|
||||
drawable.getIntrinsicWidth(),
|
||||
android.graphics.Bitmap bitmap = android.graphics.Bitmap
|
||||
.createBitmap(drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(),
|
||||
Config.ARGB_8888);
|
||||
|
||||
|
@ -92,8 +92,10 @@ class AndroidPaint implements Paint {
|
||||
}
|
||||
|
||||
android.graphics.Bitmap androidBitmap = android.graphics.Bitmap
|
||||
.createBitmap(bitmap.getPixels(), bitmap.getWidth(),
|
||||
bitmap.getHeight(), Config.ARGB_8888);
|
||||
.createBitmap(bitmap.getPixels(),
|
||||
bitmap.getWidth(),
|
||||
bitmap.getHeight(),
|
||||
Config.ARGB_8888);
|
||||
Shader shader = new BitmapShader(androidBitmap, TileMode.REPEAT,
|
||||
TileMode.REPEAT);
|
||||
mPaint.setShader(shader);
|
||||
|
@ -24,7 +24,6 @@ import android.opengl.GLES20;
|
||||
|
||||
public class AndroidGL implements GL20 {
|
||||
|
||||
|
||||
@Override
|
||||
public void glAttachShader(int program, int shader) {
|
||||
GLES20.glAttachShader(program, shader);
|
||||
|
@ -13,6 +13,7 @@
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.input;
|
||||
|
||||
import org.oscim.event.MotionEvent;
|
||||
|
||||
public class AndroidMotionEvent extends MotionEvent {
|
||||
@ -36,6 +37,7 @@ public class AndroidMotionEvent extends MotionEvent {
|
||||
public int getAction() {
|
||||
return mEvent.getAction();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getX() {
|
||||
return mEvent.getX();
|
||||
@ -66,5 +68,4 @@ public class AndroidMotionEvent extends MotionEvent {
|
||||
return mEvent.getEventTime();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class OSMMember {
|
||||
WAY,
|
||||
RELATIOM
|
||||
}
|
||||
|
||||
static final boolean useDebugLabels = true;
|
||||
|
||||
public final String role;
|
||||
|
@ -16,9 +16,6 @@ import org.oscim.utils.osm.OSMNode;
|
||||
import org.oscim.utils.osm.OSMRelation;
|
||||
import org.oscim.utils.osm.OSMWay;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Class that reads and parses binary files and sends the contained entities to
|
||||
* the sink.
|
||||
@ -205,7 +202,6 @@ public class OsmPbfParser extends BinaryParser {
|
||||
for (int j = 0; j < tagCnt; j++)
|
||||
tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
|
||||
|
||||
|
||||
long id = i.getId();
|
||||
|
||||
long lastMid = 0;
|
||||
@ -310,7 +306,6 @@ public class OsmPbfParser extends BinaryParser {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// give up references to original collections
|
||||
|
||||
ArrayList<OSMWay> ways = new ArrayList<OSMWay>(mWayMap.values());
|
||||
|
@ -322,7 +322,6 @@ public class OverpassAPIReader {
|
||||
|
||||
TagSet tags = null;
|
||||
|
||||
|
||||
while (jp.nextToken() != JsonToken.END_OBJECT) {
|
||||
String key = jp.getCurrentName();
|
||||
jp.nextToken();
|
||||
@ -343,7 +342,6 @@ public class OverpassAPIReader {
|
||||
System.out.println(msg);
|
||||
}
|
||||
|
||||
|
||||
public OSMData getData() {
|
||||
|
||||
String encoded;
|
||||
|
@ -193,7 +193,6 @@ public class WKBReader {
|
||||
if (i > 0)
|
||||
mGeom.startHole();
|
||||
|
||||
|
||||
int points = data.getInt();
|
||||
|
||||
for (int j = 0; j < points; j++) {
|
||||
|
@ -16,7 +16,6 @@ package org.oscim.android;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class AndroidLog implements org.oscim.backend.Log.Logger {
|
||||
|
||||
@Override
|
||||
|
@ -35,6 +35,7 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
mBitmap = android.graphics.Bitmap
|
||||
.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
|
||||
AndroidBitmap(android.graphics.Bitmap bitmap) {
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public class AndroidCanvas implements Canvas {
|
||||
public AndroidCanvas() {
|
||||
this.canvas = new android.graphics.Canvas();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
|
||||
@ -20,6 +21,7 @@ public class AndroidCanvas implements Canvas {
|
||||
this.canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
this.canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
|
||||
|
@ -94,8 +94,8 @@ public final class AndroidGraphics extends CanvasAdapter {
|
||||
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
|
||||
}
|
||||
|
||||
android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(
|
||||
drawable.getIntrinsicWidth(),
|
||||
android.graphics.Bitmap bitmap = android.graphics.Bitmap
|
||||
.createBitmap(drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(),
|
||||
Config.ARGB_8888);
|
||||
|
||||
|
@ -62,8 +62,7 @@ class AndroidPaint implements Paint {
|
||||
final android.graphics.Paint mPaint;
|
||||
|
||||
AndroidPaint() {
|
||||
mPaint = new android.graphics.Paint(
|
||||
android.graphics.Paint.ANTI_ALIAS_FLAG);
|
||||
mPaint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,14 +48,14 @@ public class AwtCanvas implements Canvas {
|
||||
|
||||
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
|
||||
|
||||
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_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
canvas.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(String text, float x, float y, Paint paint) {
|
||||
|
||||
@ -73,7 +73,9 @@ public class AwtCanvas implements Canvas {
|
||||
canvas.drawString(text, x + 2, y);
|
||||
} else {
|
||||
setColorAndStroke(awtPaint);
|
||||
TextLayout textLayout = new TextLayout(text, awtPaint.font, canvas.getFontRenderContext());
|
||||
TextLayout textLayout = new TextLayout(text,
|
||||
awtPaint.font,
|
||||
canvas.getFontRenderContext());
|
||||
AffineTransform affineTransform = new AffineTransform();
|
||||
affineTransform.translate(x + 2, y);
|
||||
canvas.draw(textLayout.getOutline(affineTransform));
|
||||
|
@ -54,10 +54,12 @@ public class AwtGraphics extends CanvasAdapter {
|
||||
static {
|
||||
image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
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_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
}
|
||||
|
||||
static synchronized FontMetrics getFontMetrics(Font font) {
|
||||
canvas.setFont(font);
|
||||
// get character measurements
|
||||
|
@ -60,6 +60,7 @@ public class AwtPaint implements Paint {
|
||||
|
||||
private int cap;
|
||||
private float strokeWidth;
|
||||
|
||||
//private Align mAlign;
|
||||
|
||||
@Override
|
||||
|
890
vtm-gdx-desktop/src/org/oscim/gdx/GdxGL20.java
Normal file
890
vtm-gdx-desktop/src/org/oscim/gdx/GdxGL20.java
Normal file
@ -0,0 +1,890 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011 See AUTHORS file.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
package org.oscim.gdx;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.EXTFramebufferObject;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.badlogic.gdx.graphics.GL10;
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
|
||||
/**
|
||||
* An implementation of the {@link GL20} interface based on LWJGL. Note that
|
||||
* LWJGL shaders and OpenGL ES shaders will not be 100%
|
||||
* compatible. Some glGetXXX methods are not implemented.
|
||||
*
|
||||
* @author mzechner
|
||||
*/
|
||||
public final class GdxGL20 implements org.oscim.backend.GL20 {
|
||||
public void glActiveTexture(int texture) {
|
||||
GL13.glActiveTexture(texture);
|
||||
}
|
||||
|
||||
public void glAttachShader(int program, int shader) {
|
||||
GL20.glAttachShader(program, shader);
|
||||
}
|
||||
|
||||
public void glBindAttribLocation(int program, int index, String name) {
|
||||
GL20.glBindAttribLocation(program, index, name);
|
||||
}
|
||||
|
||||
public void glBindBuffer(int target, int buffer) {
|
||||
GL15.glBindBuffer(target, buffer);
|
||||
}
|
||||
|
||||
public void glBindFramebuffer(int target, int framebuffer) {
|
||||
EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer);
|
||||
}
|
||||
|
||||
public void glBindRenderbuffer(int target, int renderbuffer) {
|
||||
EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer);
|
||||
}
|
||||
|
||||
public void glBindTexture(int target, int texture) {
|
||||
GL11.glBindTexture(target, texture);
|
||||
}
|
||||
|
||||
public void glBlendColor(float red, float green, float blue, float alpha) {
|
||||
GL14.glBlendColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glBlendEquation(int mode) {
|
||||
GL14.glBlendEquation(mode);
|
||||
}
|
||||
|
||||
public void glBlendEquationSeparate(int modeRGB, int modeAlpha) {
|
||||
GL20.glBlendEquationSeparate(modeRGB, modeAlpha);
|
||||
}
|
||||
|
||||
public void glBlendFunc(int sfactor, int dfactor) {
|
||||
GL11.glBlendFunc(sfactor, dfactor);
|
||||
}
|
||||
|
||||
public void glBlendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
|
||||
GL14.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
public void glBufferData(int target, int size, Buffer data, int usage) {
|
||||
if (data == null)
|
||||
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
|
||||
else if (data instanceof ByteBuffer)
|
||||
GL15.glBufferData(target, (ByteBuffer) data, usage);
|
||||
else if (data instanceof IntBuffer)
|
||||
GL15.glBufferData(target, (IntBuffer) data, usage);
|
||||
else if (data instanceof FloatBuffer)
|
||||
GL15.glBufferData(target, (FloatBuffer) data, usage);
|
||||
else if (data instanceof DoubleBuffer)
|
||||
GL15.glBufferData(target, (DoubleBuffer) data, usage);
|
||||
else if (data instanceof ShortBuffer) //
|
||||
GL15.glBufferData(target, (ShortBuffer) data, usage);
|
||||
}
|
||||
|
||||
public void glBufferSubData(int target, int offset, int size, Buffer data) {
|
||||
if (data == null)
|
||||
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
|
||||
else if (data instanceof ByteBuffer)
|
||||
GL15.glBufferSubData(target, offset, (ByteBuffer) data);
|
||||
else if (data instanceof IntBuffer)
|
||||
GL15.glBufferSubData(target, offset, (IntBuffer) data);
|
||||
else if (data instanceof FloatBuffer)
|
||||
GL15.glBufferSubData(target, offset, (FloatBuffer) data);
|
||||
else if (data instanceof DoubleBuffer)
|
||||
GL15.glBufferSubData(target, offset, (DoubleBuffer) data);
|
||||
else if (data instanceof ShortBuffer) //
|
||||
GL15.glBufferSubData(target, offset, (ShortBuffer) data);
|
||||
}
|
||||
|
||||
public int glCheckFramebufferStatus(int target) {
|
||||
return EXTFramebufferObject.glCheckFramebufferStatusEXT(target);
|
||||
}
|
||||
|
||||
public void glClear(int mask) {
|
||||
GL11.glClear(mask);
|
||||
}
|
||||
|
||||
public void glClearColor(float red, float green, float blue, float alpha) {
|
||||
GL11.glClearColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glClearDepthf(float depth) {
|
||||
GL11.glClearDepth(depth);
|
||||
}
|
||||
|
||||
public void glClearStencil(int s) {
|
||||
GL11.glClearStencil(s);
|
||||
}
|
||||
|
||||
public void glColorMask(boolean red, boolean green, boolean blue, boolean alpha) {
|
||||
GL11.glColorMask(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glCompileShader(int shader) {
|
||||
GL20.glCompileShader(shader);
|
||||
}
|
||||
|
||||
public void glCompressedTexImage2D(int target, int level, int internalformat, int width,
|
||||
int height, int border,
|
||||
int imageSize, Buffer data) {
|
||||
if (data instanceof ByteBuffer) {
|
||||
GL13.glCompressedTexImage2D(target,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
border,
|
||||
(ByteBuffer) data);
|
||||
} else {
|
||||
throw new GdxRuntimeException("Can't use " + data.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer instead.");
|
||||
}
|
||||
}
|
||||
|
||||
public void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset,
|
||||
int width, int height, int format,
|
||||
int imageSize, Buffer data) {
|
||||
throw new GdxRuntimeException("not implemented");
|
||||
}
|
||||
|
||||
public void glCopyTexImage2D(int target, int level, int internalformat, int x, int y,
|
||||
int width, int height, int border) {
|
||||
GL11.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
|
||||
}
|
||||
|
||||
public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
|
||||
int width, int height) {
|
||||
GL11.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
||||
}
|
||||
|
||||
public int glCreateProgram() {
|
||||
return GL20.glCreateProgram();
|
||||
}
|
||||
|
||||
public int glCreateShader(int type) {
|
||||
return GL20.glCreateShader(type);
|
||||
}
|
||||
|
||||
public void glCullFace(int mode) {
|
||||
GL11.glCullFace(mode);
|
||||
}
|
||||
|
||||
public void glDeleteBuffers(int n, IntBuffer buffers) {
|
||||
GL15.glDeleteBuffers(buffers);
|
||||
}
|
||||
|
||||
public void glDeleteFramebuffers(int n, IntBuffer framebuffers) {
|
||||
EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffers);
|
||||
}
|
||||
|
||||
public void glDeleteProgram(int program) {
|
||||
GL20.glDeleteProgram(program);
|
||||
}
|
||||
|
||||
public void glDeleteRenderbuffers(int n, IntBuffer renderbuffers) {
|
||||
EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffers);
|
||||
}
|
||||
|
||||
public void glDeleteShader(int shader) {
|
||||
GL20.glDeleteShader(shader);
|
||||
}
|
||||
|
||||
public void glDeleteTextures(int n, IntBuffer textures) {
|
||||
GL11.glDeleteTextures(textures);
|
||||
}
|
||||
|
||||
public void glDepthFunc(int func) {
|
||||
GL11.glDepthFunc(func);
|
||||
}
|
||||
|
||||
public void glDepthMask(boolean flag) {
|
||||
GL11.glDepthMask(flag);
|
||||
}
|
||||
|
||||
public void glDepthRangef(float zNear, float zFar) {
|
||||
GL11.glDepthRange(zNear, zFar);
|
||||
}
|
||||
|
||||
public void glDetachShader(int program, int shader) {
|
||||
GL20.glDetachShader(program, shader);
|
||||
}
|
||||
|
||||
public void glDisable(int cap) {
|
||||
GL11.glDisable(cap);
|
||||
}
|
||||
|
||||
public void glDisableVertexAttribArray(int index) {
|
||||
GL20.glDisableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
public void glDrawArrays(int mode, int first, int count) {
|
||||
GL11.glDrawArrays(mode, first, count);
|
||||
}
|
||||
|
||||
public void glDrawElements(int mode, int count, int type, Buffer indices) {
|
||||
if (indices instanceof ShortBuffer && type == GL10.GL_UNSIGNED_SHORT)
|
||||
GL11.glDrawElements(mode, (ShortBuffer) indices);
|
||||
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_SHORT)
|
||||
GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); // FIXME yay...
|
||||
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_BYTE)
|
||||
GL11.glDrawElements(mode, (ByteBuffer) indices);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use " + indices.getClass().getName()
|
||||
+ " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glEnable(int cap) {
|
||||
GL11.glEnable(cap);
|
||||
}
|
||||
|
||||
public void glEnableVertexAttribArray(int index) {
|
||||
GL20.glEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
public void glFinish() {
|
||||
GL11.glFinish();
|
||||
}
|
||||
|
||||
public void glFlush() {
|
||||
GL11.glFlush();
|
||||
}
|
||||
|
||||
public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget,
|
||||
int renderbuffer) {
|
||||
EXTFramebufferObject.glFramebufferRenderbufferEXT(target,
|
||||
attachment,
|
||||
renderbuffertarget,
|
||||
renderbuffer);
|
||||
}
|
||||
|
||||
public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture,
|
||||
int level) {
|
||||
EXTFramebufferObject.glFramebufferTexture2DEXT(target,
|
||||
attachment,
|
||||
textarget,
|
||||
texture,
|
||||
level);
|
||||
}
|
||||
|
||||
public void glFrontFace(int mode) {
|
||||
GL11.glFrontFace(mode);
|
||||
}
|
||||
|
||||
public void glGenBuffers(int n, IntBuffer buffers) {
|
||||
GL15.glGenBuffers(buffers);
|
||||
}
|
||||
|
||||
public void glGenFramebuffers(int n, IntBuffer framebuffers) {
|
||||
EXTFramebufferObject.glGenFramebuffersEXT(framebuffers);
|
||||
}
|
||||
|
||||
public void glGenRenderbuffers(int n, IntBuffer renderbuffers) {
|
||||
EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers);
|
||||
}
|
||||
|
||||
public void glGenTextures(int n, IntBuffer textures) {
|
||||
GL11.glGenTextures(textures);
|
||||
}
|
||||
|
||||
public void glGenerateMipmap(int target) {
|
||||
EXTFramebufferObject.glGenerateMipmapEXT(target);
|
||||
}
|
||||
|
||||
public String glGetActiveAttrib(int program, int index, IntBuffer size, Buffer type) {
|
||||
// FIXME this is less than ideal of course...
|
||||
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
|
||||
String name = GL20.glGetActiveAttrib(program, index, 256, typeTmp);
|
||||
if (type instanceof IntBuffer)
|
||||
((IntBuffer) type).put(typeTmp.get(0));
|
||||
return name;
|
||||
}
|
||||
|
||||
public String glGetActiveUniform(int program, int index, IntBuffer size, Buffer type) {
|
||||
// FIXME this is less than ideal of course...
|
||||
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
|
||||
String name = GL20.glGetActiveUniform(program, index, 256, typeTmp);
|
||||
if (type instanceof IntBuffer)
|
||||
((IntBuffer) type).put(typeTmp.get(0));
|
||||
return name;
|
||||
}
|
||||
|
||||
public void glGetAttachedShaders(int program, int maxcount, Buffer count, IntBuffer shaders) {
|
||||
GL20.glGetAttachedShaders(program, (IntBuffer) count, shaders);
|
||||
}
|
||||
|
||||
public int glGetAttribLocation(int program, String name) {
|
||||
return GL20.glGetAttribLocation(program, name);
|
||||
}
|
||||
|
||||
public void glGetBooleanv(int pname, Buffer params) {
|
||||
GL11.glGetBoolean(pname, (ByteBuffer) params);
|
||||
}
|
||||
|
||||
public void glGetBufferParameteriv(int target, int pname, IntBuffer params) {
|
||||
GL15.glGetBufferParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public int glGetError() {
|
||||
return GL11.glGetError();
|
||||
}
|
||||
|
||||
public void glGetFloatv(int pname, FloatBuffer params) {
|
||||
GL11.glGetFloat(pname, params);
|
||||
}
|
||||
|
||||
public void glGetFramebufferAttachmentParameteriv(int target, int attachment, int pname,
|
||||
IntBuffer params) {
|
||||
EXTFramebufferObject.glGetFramebufferAttachmentParameterEXT(target,
|
||||
attachment,
|
||||
pname,
|
||||
params);
|
||||
}
|
||||
|
||||
public void glGetIntegerv(int pname, IntBuffer params) {
|
||||
GL11.glGetInteger(pname, params);
|
||||
}
|
||||
|
||||
public String glGetProgramInfoLog(int program) {
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
|
||||
buffer.order(ByteOrder.nativeOrder());
|
||||
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
|
||||
tmp.order(ByteOrder.nativeOrder());
|
||||
IntBuffer intBuffer = tmp.asIntBuffer();
|
||||
|
||||
GL20.glGetProgramInfoLog(program, intBuffer, buffer);
|
||||
int numBytes = intBuffer.get(0);
|
||||
byte[] bytes = new byte[numBytes];
|
||||
buffer.get(bytes);
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public void glGetProgramiv(int program, int pname, IntBuffer params) {
|
||||
GL20.glGetProgram(program, pname, params);
|
||||
}
|
||||
|
||||
public void glGetRenderbufferParameteriv(int target, int pname, IntBuffer params) {
|
||||
EXTFramebufferObject.glGetRenderbufferParameterEXT(target, pname, params);
|
||||
}
|
||||
|
||||
public String glGetShaderInfoLog(int shader) {
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
|
||||
buffer.order(ByteOrder.nativeOrder());
|
||||
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
|
||||
tmp.order(ByteOrder.nativeOrder());
|
||||
IntBuffer intBuffer = tmp.asIntBuffer();
|
||||
|
||||
GL20.glGetShaderInfoLog(shader, intBuffer, buffer);
|
||||
int numBytes = intBuffer.get(0);
|
||||
byte[] bytes = new byte[numBytes];
|
||||
buffer.get(bytes);
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public void glGetShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range,
|
||||
IntBuffer precision) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement");
|
||||
}
|
||||
|
||||
public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement.");
|
||||
}
|
||||
|
||||
public void glGetShaderiv(int shader, int pname, IntBuffer params) {
|
||||
GL20.glGetShader(shader, pname, params);
|
||||
}
|
||||
|
||||
public String glGetString(int name) {
|
||||
return GL11.glGetString(name);
|
||||
}
|
||||
|
||||
public void glGetTexParameterfv(int target, int pname, FloatBuffer params) {
|
||||
GL11.glGetTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public void glGetTexParameteriv(int target, int pname, IntBuffer params) {
|
||||
GL11.glGetTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public int glGetUniformLocation(int program, String name) {
|
||||
return GL20.glGetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
public void glGetUniformfv(int program, int location, FloatBuffer params) {
|
||||
GL20.glGetUniform(program, location, params);
|
||||
}
|
||||
|
||||
public void glGetUniformiv(int program, int location, IntBuffer params) {
|
||||
GL20.glGetUniform(program, location, params);
|
||||
}
|
||||
|
||||
public void glGetVertexAttribPointerv(int index, int pname, Buffer pointer) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement");
|
||||
}
|
||||
|
||||
public void glGetVertexAttribfv(int index, int pname, FloatBuffer params) {
|
||||
GL20.glGetVertexAttrib(index, pname, params);
|
||||
}
|
||||
|
||||
public void glGetVertexAttribiv(int index, int pname, IntBuffer params) {
|
||||
GL20.glGetVertexAttrib(index, pname, params);
|
||||
}
|
||||
|
||||
public void glHint(int target, int mode) {
|
||||
GL11.glHint(target, mode);
|
||||
}
|
||||
|
||||
public boolean glIsBuffer(int buffer) {
|
||||
return GL15.glIsBuffer(buffer);
|
||||
}
|
||||
|
||||
public boolean glIsEnabled(int cap) {
|
||||
return GL11.glIsEnabled(cap);
|
||||
}
|
||||
|
||||
public boolean glIsFramebuffer(int framebuffer) {
|
||||
return EXTFramebufferObject.glIsFramebufferEXT(framebuffer);
|
||||
}
|
||||
|
||||
public boolean glIsProgram(int program) {
|
||||
return GL20.glIsProgram(program);
|
||||
}
|
||||
|
||||
public boolean glIsRenderbuffer(int renderbuffer) {
|
||||
return EXTFramebufferObject.glIsRenderbufferEXT(renderbuffer);
|
||||
}
|
||||
|
||||
public boolean glIsShader(int shader) {
|
||||
return GL20.glIsShader(shader);
|
||||
}
|
||||
|
||||
public boolean glIsTexture(int texture) {
|
||||
return GL11.glIsTexture(texture);
|
||||
}
|
||||
|
||||
public void glLineWidth(float width) {
|
||||
GL11.glLineWidth(width);
|
||||
}
|
||||
|
||||
public void glLinkProgram(int program) {
|
||||
GL20.glLinkProgram(program);
|
||||
}
|
||||
|
||||
public void glPixelStorei(int pname, int param) {
|
||||
GL11.glPixelStorei(pname, param);
|
||||
}
|
||||
|
||||
public void glPolygonOffset(float factor, float units) {
|
||||
GL11.glPolygonOffset(factor, units);
|
||||
}
|
||||
|
||||
public void glReadPixels(int x, int y, int width, int height, int format, int type,
|
||||
Buffer pixels) {
|
||||
if (pixels instanceof ByteBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (ByteBuffer) pixels);
|
||||
else if (pixels instanceof ShortBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (ShortBuffer) pixels);
|
||||
else if (pixels instanceof IntBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (IntBuffer) pixels);
|
||||
else if (pixels instanceof FloatBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (FloatBuffer) pixels);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use "
|
||||
+ pixels.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer or FloatBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glReleaseShaderCompiler() {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
public void glRenderbufferStorage(int target, int internalformat, int width, int height) {
|
||||
EXTFramebufferObject.glRenderbufferStorageEXT(target, internalformat, width, height);
|
||||
}
|
||||
|
||||
public void glSampleCoverage(float value, boolean invert) {
|
||||
GL13.glSampleCoverage(value, invert);
|
||||
}
|
||||
|
||||
public void glScissor(int x, int y, int width, int height) {
|
||||
GL11.glScissor(x, y, width, height);
|
||||
}
|
||||
|
||||
public void glShaderBinary(int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement");
|
||||
}
|
||||
|
||||
public void glShaderSource(int shader, String string) {
|
||||
GL20.glShaderSource(shader, string);
|
||||
}
|
||||
|
||||
public void glStencilFunc(int func, int ref, int mask) {
|
||||
GL11.glStencilFunc(func, ref, mask);
|
||||
}
|
||||
|
||||
public void glStencilFuncSeparate(int face, int func, int ref, int mask) {
|
||||
GL20.glStencilFuncSeparate(face, func, ref, mask);
|
||||
}
|
||||
|
||||
public void glStencilMask(int mask) {
|
||||
GL11.glStencilMask(mask);
|
||||
}
|
||||
|
||||
public void glStencilMaskSeparate(int face, int mask) {
|
||||
GL20.glStencilMaskSeparate(face, mask);
|
||||
}
|
||||
|
||||
public void glStencilOp(int fail, int zfail, int zpass) {
|
||||
GL11.glStencilOp(fail, zfail, zpass);
|
||||
}
|
||||
|
||||
public void glStencilOpSeparate(int face, int fail, int zfail, int zpass) {
|
||||
GL20.glStencilOpSeparate(face, fail, zfail, zpass);
|
||||
}
|
||||
|
||||
public void glTexImage2D(int target, int level, int internalformat, int width, int height,
|
||||
int border, int format, int type,
|
||||
Buffer pixels) {
|
||||
if (pixels == null)
|
||||
GL11.glTexImage2D(target,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
border,
|
||||
format,
|
||||
type,
|
||||
(ByteBuffer) null);
|
||||
else if (pixels instanceof ByteBuffer)
|
||||
GL11.glTexImage2D(target,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
border,
|
||||
format,
|
||||
type,
|
||||
(ByteBuffer) pixels);
|
||||
else if (pixels instanceof ShortBuffer)
|
||||
GL11.glTexImage2D(target,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
border,
|
||||
format,
|
||||
type,
|
||||
(ShortBuffer) pixels);
|
||||
else if (pixels instanceof IntBuffer)
|
||||
GL11.glTexImage2D(target,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
border,
|
||||
format,
|
||||
type,
|
||||
(IntBuffer) pixels);
|
||||
else if (pixels instanceof FloatBuffer)
|
||||
GL11.glTexImage2D(target,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
border,
|
||||
format,
|
||||
type,
|
||||
(FloatBuffer) pixels);
|
||||
else if (pixels instanceof DoubleBuffer)
|
||||
GL11.glTexImage2D(target,
|
||||
level,
|
||||
internalformat,
|
||||
width,
|
||||
height,
|
||||
border,
|
||||
format,
|
||||
type,
|
||||
(DoubleBuffer) pixels);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use "
|
||||
+ pixels.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glTexParameterf(int target, int pname, float param) {
|
||||
GL11.glTexParameterf(target, pname, param);
|
||||
}
|
||||
|
||||
public void glTexParameterfv(int target, int pname, FloatBuffer params) {
|
||||
GL11.glTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public void glTexParameteri(int target, int pname, int param) {
|
||||
GL11.glTexParameteri(target, pname, param);
|
||||
}
|
||||
|
||||
public void glTexParameteriv(int target, int pname, IntBuffer params) {
|
||||
GL11.glTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width,
|
||||
int height, int format, int type,
|
||||
Buffer pixels) {
|
||||
if (pixels instanceof ByteBuffer)
|
||||
GL11.glTexSubImage2D(target,
|
||||
level,
|
||||
xoffset,
|
||||
yoffset,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
type,
|
||||
(ByteBuffer) pixels);
|
||||
else if (pixels instanceof ShortBuffer)
|
||||
GL11.glTexSubImage2D(target,
|
||||
level,
|
||||
xoffset,
|
||||
yoffset,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
type,
|
||||
(ShortBuffer) pixels);
|
||||
else if (pixels instanceof IntBuffer)
|
||||
GL11.glTexSubImage2D(target,
|
||||
level,
|
||||
xoffset,
|
||||
yoffset,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
type,
|
||||
(IntBuffer) pixels);
|
||||
else if (pixels instanceof FloatBuffer)
|
||||
GL11.glTexSubImage2D(target,
|
||||
level,
|
||||
xoffset,
|
||||
yoffset,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
type,
|
||||
(FloatBuffer) pixels);
|
||||
else if (pixels instanceof DoubleBuffer)
|
||||
GL11.glTexSubImage2D(target,
|
||||
level,
|
||||
xoffset,
|
||||
yoffset,
|
||||
width,
|
||||
height,
|
||||
format,
|
||||
type,
|
||||
(DoubleBuffer) pixels);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use "
|
||||
+ pixels.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glUniform1f(int location, float x) {
|
||||
GL20.glUniform1f(location, x);
|
||||
}
|
||||
|
||||
public void glUniform1fv(int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform1(location, v);
|
||||
}
|
||||
|
||||
public void glUniform1i(int location, int x) {
|
||||
GL20.glUniform1i(location, x);
|
||||
}
|
||||
|
||||
public void glUniform1iv(int location, int count, IntBuffer v) {
|
||||
GL20.glUniform1(location, v);
|
||||
}
|
||||
|
||||
public void glUniform2f(int location, float x, float y) {
|
||||
GL20.glUniform2f(location, x, y);
|
||||
}
|
||||
|
||||
public void glUniform2fv(int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform2(location, v);
|
||||
}
|
||||
|
||||
public void glUniform2i(int location, int x, int y) {
|
||||
GL20.glUniform2i(location, x, y);
|
||||
}
|
||||
|
||||
public void glUniform2iv(int location, int count, IntBuffer v) {
|
||||
GL20.glUniform2(location, v);
|
||||
}
|
||||
|
||||
public void glUniform3f(int location, float x, float y, float z) {
|
||||
GL20.glUniform3f(location, x, y, z);
|
||||
}
|
||||
|
||||
public void glUniform3fv(int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform3(location, v);
|
||||
}
|
||||
|
||||
public void glUniform3i(int location, int x, int y, int z) {
|
||||
GL20.glUniform3i(location, x, y, z);
|
||||
}
|
||||
|
||||
public void glUniform3iv(int location, int count, IntBuffer v) {
|
||||
GL20.glUniform3(location, v);
|
||||
}
|
||||
|
||||
public void glUniform4f(int location, float x, float y, float z, float w) {
|
||||
GL20.glUniform4f(location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void glUniform4fv(int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform4(location, v);
|
||||
}
|
||||
|
||||
public void glUniform4i(int location, int x, int y, int z, int w) {
|
||||
GL20.glUniform4i(location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void glUniform4iv(int location, int count, IntBuffer v) {
|
||||
GL20.glUniform4(location, v);
|
||||
}
|
||||
|
||||
public void glUniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix2(location, transpose, value);
|
||||
}
|
||||
|
||||
public void glUniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix3(location, transpose, value);
|
||||
}
|
||||
|
||||
public void glUniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix4(location, transpose, value);
|
||||
}
|
||||
|
||||
public void glUseProgram(int program) {
|
||||
GL20.glUseProgram(program);
|
||||
}
|
||||
|
||||
public void glValidateProgram(int program) {
|
||||
GL20.glValidateProgram(program);
|
||||
}
|
||||
|
||||
public void glVertexAttrib1f(int indx, float x) {
|
||||
GL20.glVertexAttrib1f(indx, x);
|
||||
}
|
||||
|
||||
public void glVertexAttrib1fv(int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib1f(indx, values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttrib2f(int indx, float x, float y) {
|
||||
GL20.glVertexAttrib2f(indx, x, y);
|
||||
}
|
||||
|
||||
public void glVertexAttrib2fv(int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib2f(indx, values.get(), values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttrib3f(int indx, float x, float y, float z) {
|
||||
GL20.glVertexAttrib3f(indx, x, y, z);
|
||||
}
|
||||
|
||||
public void glVertexAttrib3fv(int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib3f(indx, values.get(), values.get(), values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttrib4f(int indx, float x, float y, float z, float w) {
|
||||
GL20.glVertexAttrib4f(indx, x, y, z, w);
|
||||
}
|
||||
|
||||
public void glVertexAttrib4fv(int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib4f(indx, values.get(), values.get(), values.get(), values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
|
||||
Buffer buffer) {
|
||||
if (buffer instanceof ByteBuffer) {
|
||||
if (type == GL_BYTE)
|
||||
GL20.glVertexAttribPointer(indx,
|
||||
size,
|
||||
false,
|
||||
normalized,
|
||||
stride,
|
||||
(ByteBuffer) buffer);
|
||||
else if (type == GL_UNSIGNED_BYTE)
|
||||
GL20.glVertexAttribPointer(indx,
|
||||
size,
|
||||
true,
|
||||
normalized,
|
||||
stride,
|
||||
(ByteBuffer) buffer);
|
||||
else if (type == GL_SHORT)
|
||||
GL20.glVertexAttribPointer(indx,
|
||||
size,
|
||||
false,
|
||||
normalized,
|
||||
stride,
|
||||
((ByteBuffer) buffer).asShortBuffer());
|
||||
else if (type == GL_UNSIGNED_SHORT)
|
||||
GL20.glVertexAttribPointer(indx,
|
||||
size,
|
||||
true,
|
||||
normalized,
|
||||
stride,
|
||||
((ByteBuffer) buffer).asShortBuffer());
|
||||
else if (type == GL_FLOAT)
|
||||
GL20.glVertexAttribPointer(indx,
|
||||
size,
|
||||
normalized,
|
||||
stride,
|
||||
((ByteBuffer) buffer).asFloatBuffer());
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use "
|
||||
+ buffer.getClass().getName()
|
||||
+ " with type "
|
||||
+ type
|
||||
+ " with this method. Use ByteBuffer and one of GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT or GL_FLOAT for type. Blame LWJGL");
|
||||
} else
|
||||
throw new GdxRuntimeException("Can't use " + buffer.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glViewport(int x, int y, int width, int height) {
|
||||
GL11.glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
public void glDrawElements(int mode, int count, int type, int indices) {
|
||||
GL11.glDrawElements(mode, count, type, indices);
|
||||
}
|
||||
|
||||
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
|
||||
int ptr) {
|
||||
GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
|
||||
}
|
||||
|
||||
}
|
@ -1,742 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2011 See AUTHORS file.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
package org.oscim.gdx;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.DoubleBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.EXTFramebufferObject;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL13;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
import org.lwjgl.opengl.GL15;
|
||||
import org.lwjgl.opengl.GL20;
|
||||
|
||||
import com.badlogic.gdx.graphics.GL10;
|
||||
import com.badlogic.gdx.utils.GdxRuntimeException;
|
||||
|
||||
/** An implementation of the {@link GL20} interface based on LWJGL. Note that LWJGL shaders and OpenGL ES shaders will not be 100%
|
||||
* compatible. Some glGetXXX methods are not implemented.
|
||||
*
|
||||
* @author mzechner */
|
||||
public final class GdxGLAdapter implements org.oscim.backend.GL20 {
|
||||
public void glActiveTexture (int texture) {
|
||||
GL13.glActiveTexture(texture);
|
||||
}
|
||||
|
||||
public void glAttachShader (int program, int shader) {
|
||||
GL20.glAttachShader(program, shader);
|
||||
}
|
||||
|
||||
public void glBindAttribLocation (int program, int index, String name) {
|
||||
GL20.glBindAttribLocation(program, index, name);
|
||||
}
|
||||
|
||||
public void glBindBuffer (int target, int buffer) {
|
||||
GL15.glBindBuffer(target, buffer);
|
||||
}
|
||||
|
||||
public void glBindFramebuffer (int target, int framebuffer) {
|
||||
EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer);
|
||||
}
|
||||
|
||||
public void glBindRenderbuffer (int target, int renderbuffer) {
|
||||
EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer);
|
||||
}
|
||||
|
||||
public void glBindTexture (int target, int texture) {
|
||||
GL11.glBindTexture(target, texture);
|
||||
}
|
||||
|
||||
public void glBlendColor (float red, float green, float blue, float alpha) {
|
||||
GL14.glBlendColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glBlendEquation (int mode) {
|
||||
GL14.glBlendEquation(mode);
|
||||
}
|
||||
|
||||
public void glBlendEquationSeparate (int modeRGB, int modeAlpha) {
|
||||
GL20.glBlendEquationSeparate(modeRGB, modeAlpha);
|
||||
}
|
||||
|
||||
public void glBlendFunc (int sfactor, int dfactor) {
|
||||
GL11.glBlendFunc(sfactor, dfactor);
|
||||
}
|
||||
|
||||
public void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
|
||||
GL14.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
public void glBufferData (int target, int size, Buffer data, int usage) {
|
||||
if(data == null)
|
||||
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
|
||||
else if (data instanceof ByteBuffer)
|
||||
GL15.glBufferData(target, (ByteBuffer)data, usage);
|
||||
else if (data instanceof IntBuffer)
|
||||
GL15.glBufferData(target, (IntBuffer)data, usage);
|
||||
else if (data instanceof FloatBuffer)
|
||||
GL15.glBufferData(target, (FloatBuffer)data, usage);
|
||||
else if (data instanceof DoubleBuffer)
|
||||
GL15.glBufferData(target, (DoubleBuffer)data, usage);
|
||||
else if (data instanceof ShortBuffer) //
|
||||
GL15.glBufferData(target, (ShortBuffer)data, usage);
|
||||
}
|
||||
|
||||
public void glBufferSubData (int target, int offset, int size, Buffer data) {
|
||||
if(data == null)
|
||||
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
|
||||
else if (data instanceof ByteBuffer)
|
||||
GL15.glBufferSubData(target, offset, (ByteBuffer)data);
|
||||
else if (data instanceof IntBuffer)
|
||||
GL15.glBufferSubData(target, offset, (IntBuffer)data);
|
||||
else if (data instanceof FloatBuffer)
|
||||
GL15.glBufferSubData(target, offset, (FloatBuffer)data);
|
||||
else if (data instanceof DoubleBuffer)
|
||||
GL15.glBufferSubData(target, offset, (DoubleBuffer)data);
|
||||
else if (data instanceof ShortBuffer) //
|
||||
GL15.glBufferSubData(target, offset, (ShortBuffer)data);
|
||||
}
|
||||
|
||||
public int glCheckFramebufferStatus (int target) {
|
||||
return EXTFramebufferObject.glCheckFramebufferStatusEXT(target);
|
||||
}
|
||||
|
||||
public void glClear (int mask) {
|
||||
GL11.glClear(mask);
|
||||
}
|
||||
|
||||
public void glClearColor (float red, float green, float blue, float alpha) {
|
||||
GL11.glClearColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glClearDepthf (float depth) {
|
||||
GL11.glClearDepth(depth);
|
||||
}
|
||||
|
||||
public void glClearStencil (int s) {
|
||||
GL11.glClearStencil(s);
|
||||
}
|
||||
|
||||
public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha) {
|
||||
GL11.glColorMask(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
public void glCompileShader (int shader) {
|
||||
GL20.glCompileShader(shader);
|
||||
}
|
||||
|
||||
public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border,
|
||||
int imageSize, Buffer data) {
|
||||
if (data instanceof ByteBuffer) {
|
||||
GL13.glCompressedTexImage2D(target, level, internalformat, width, height, border, (ByteBuffer)data);
|
||||
} else {
|
||||
throw new GdxRuntimeException("Can't use " + data.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer instead.");
|
||||
}
|
||||
}
|
||||
|
||||
public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format,
|
||||
int imageSize, Buffer data) {
|
||||
throw new GdxRuntimeException("not implemented");
|
||||
}
|
||||
|
||||
public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) {
|
||||
GL11.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
|
||||
}
|
||||
|
||||
public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height) {
|
||||
GL11.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
|
||||
}
|
||||
|
||||
public int glCreateProgram () {
|
||||
return GL20.glCreateProgram();
|
||||
}
|
||||
|
||||
public int glCreateShader (int type) {
|
||||
return GL20.glCreateShader(type);
|
||||
}
|
||||
|
||||
public void glCullFace (int mode) {
|
||||
GL11.glCullFace(mode);
|
||||
}
|
||||
|
||||
public void glDeleteBuffers (int n, IntBuffer buffers) {
|
||||
GL15.glDeleteBuffers(buffers);
|
||||
}
|
||||
|
||||
public void glDeleteFramebuffers (int n, IntBuffer framebuffers) {
|
||||
EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffers);
|
||||
}
|
||||
|
||||
public void glDeleteProgram (int program) {
|
||||
GL20.glDeleteProgram(program);
|
||||
}
|
||||
|
||||
public void glDeleteRenderbuffers (int n, IntBuffer renderbuffers) {
|
||||
EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffers);
|
||||
}
|
||||
|
||||
public void glDeleteShader (int shader) {
|
||||
GL20.glDeleteShader(shader);
|
||||
}
|
||||
|
||||
public void glDeleteTextures (int n, IntBuffer textures) {
|
||||
GL11.glDeleteTextures(textures);
|
||||
}
|
||||
|
||||
public void glDepthFunc (int func) {
|
||||
GL11.glDepthFunc(func);
|
||||
}
|
||||
|
||||
public void glDepthMask (boolean flag) {
|
||||
GL11.glDepthMask(flag);
|
||||
}
|
||||
|
||||
public void glDepthRangef (float zNear, float zFar) {
|
||||
GL11.glDepthRange(zNear, zFar);
|
||||
}
|
||||
|
||||
public void glDetachShader (int program, int shader) {
|
||||
GL20.glDetachShader(program, shader);
|
||||
}
|
||||
|
||||
public void glDisable (int cap) {
|
||||
GL11.glDisable(cap);
|
||||
}
|
||||
|
||||
public void glDisableVertexAttribArray (int index) {
|
||||
GL20.glDisableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
public void glDrawArrays (int mode, int first, int count) {
|
||||
GL11.glDrawArrays(mode, first, count);
|
||||
}
|
||||
|
||||
public void glDrawElements (int mode, int count, int type, Buffer indices) {
|
||||
if (indices instanceof ShortBuffer && type == GL10.GL_UNSIGNED_SHORT)
|
||||
GL11.glDrawElements(mode, (ShortBuffer)indices);
|
||||
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_SHORT)
|
||||
GL11.glDrawElements(mode, ((ByteBuffer)indices).asShortBuffer()); // FIXME yay...
|
||||
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_BYTE)
|
||||
GL11.glDrawElements(mode, (ByteBuffer)indices);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use " + indices.getClass().getName()
|
||||
+ " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glEnable (int cap) {
|
||||
GL11.glEnable(cap);
|
||||
}
|
||||
|
||||
public void glEnableVertexAttribArray (int index) {
|
||||
GL20.glEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
public void glFinish () {
|
||||
GL11.glFinish();
|
||||
}
|
||||
|
||||
public void glFlush () {
|
||||
GL11.glFlush();
|
||||
}
|
||||
|
||||
public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer) {
|
||||
EXTFramebufferObject.glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
|
||||
}
|
||||
|
||||
public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level) {
|
||||
EXTFramebufferObject.glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
public void glFrontFace (int mode) {
|
||||
GL11.glFrontFace(mode);
|
||||
}
|
||||
|
||||
public void glGenBuffers (int n, IntBuffer buffers) {
|
||||
GL15.glGenBuffers(buffers);
|
||||
}
|
||||
|
||||
public void glGenFramebuffers (int n, IntBuffer framebuffers) {
|
||||
EXTFramebufferObject.glGenFramebuffersEXT(framebuffers);
|
||||
}
|
||||
|
||||
public void glGenRenderbuffers (int n, IntBuffer renderbuffers) {
|
||||
EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers);
|
||||
}
|
||||
|
||||
public void glGenTextures (int n, IntBuffer textures) {
|
||||
GL11.glGenTextures(textures);
|
||||
}
|
||||
|
||||
public void glGenerateMipmap (int target) {
|
||||
EXTFramebufferObject.glGenerateMipmapEXT(target);
|
||||
}
|
||||
|
||||
public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type) {
|
||||
// FIXME this is less than ideal of course...
|
||||
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
|
||||
String name = GL20.glGetActiveAttrib(program, index, 256, typeTmp);
|
||||
if (type instanceof IntBuffer) ((IntBuffer)type).put(typeTmp.get(0));
|
||||
return name;
|
||||
}
|
||||
|
||||
public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type) {
|
||||
// FIXME this is less than ideal of course...
|
||||
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
|
||||
String name = GL20.glGetActiveUniform(program, index, 256, typeTmp);
|
||||
if (type instanceof IntBuffer) ((IntBuffer)type).put(typeTmp.get(0));
|
||||
return name;
|
||||
}
|
||||
|
||||
public void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders) {
|
||||
GL20.glGetAttachedShaders(program, (IntBuffer)count, shaders);
|
||||
}
|
||||
|
||||
public int glGetAttribLocation (int program, String name) {
|
||||
return GL20.glGetAttribLocation(program, name);
|
||||
}
|
||||
|
||||
public void glGetBooleanv (int pname, Buffer params) {
|
||||
GL11.glGetBoolean(pname, (ByteBuffer)params);
|
||||
}
|
||||
|
||||
public void glGetBufferParameteriv (int target, int pname, IntBuffer params) {
|
||||
GL15.glGetBufferParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public int glGetError () {
|
||||
return GL11.glGetError();
|
||||
}
|
||||
|
||||
public void glGetFloatv (int pname, FloatBuffer params) {
|
||||
GL11.glGetFloat(pname, params);
|
||||
}
|
||||
|
||||
public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params) {
|
||||
EXTFramebufferObject.glGetFramebufferAttachmentParameterEXT(target, attachment, pname, params);
|
||||
}
|
||||
|
||||
public void glGetIntegerv (int pname, IntBuffer params) {
|
||||
GL11.glGetInteger(pname, params);
|
||||
}
|
||||
|
||||
public String glGetProgramInfoLog (int program) {
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
|
||||
buffer.order(ByteOrder.nativeOrder());
|
||||
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
|
||||
tmp.order(ByteOrder.nativeOrder());
|
||||
IntBuffer intBuffer = tmp.asIntBuffer();
|
||||
|
||||
GL20.glGetProgramInfoLog(program, intBuffer, buffer);
|
||||
int numBytes = intBuffer.get(0);
|
||||
byte[] bytes = new byte[numBytes];
|
||||
buffer.get(bytes);
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public void glGetProgramiv (int program, int pname, IntBuffer params) {
|
||||
GL20.glGetProgram(program, pname, params);
|
||||
}
|
||||
|
||||
public void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params) {
|
||||
EXTFramebufferObject.glGetRenderbufferParameterEXT(target, pname, params);
|
||||
}
|
||||
|
||||
public String glGetShaderInfoLog (int shader) {
|
||||
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
|
||||
buffer.order(ByteOrder.nativeOrder());
|
||||
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
|
||||
tmp.order(ByteOrder.nativeOrder());
|
||||
IntBuffer intBuffer = tmp.asIntBuffer();
|
||||
|
||||
GL20.glGetShaderInfoLog(shader, intBuffer, buffer);
|
||||
int numBytes = intBuffer.get(0);
|
||||
byte[] bytes = new byte[numBytes];
|
||||
buffer.get(bytes);
|
||||
return new String(bytes);
|
||||
}
|
||||
|
||||
public void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement");
|
||||
}
|
||||
|
||||
public void glGetShaderSource (int shader, int bufsize, Buffer length, String source) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement.");
|
||||
}
|
||||
|
||||
public void glGetShaderiv (int shader, int pname, IntBuffer params) {
|
||||
GL20.glGetShader(shader, pname, params);
|
||||
}
|
||||
|
||||
public String glGetString (int name) {
|
||||
return GL11.glGetString(name);
|
||||
}
|
||||
|
||||
public void glGetTexParameterfv (int target, int pname, FloatBuffer params) {
|
||||
GL11.glGetTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public void glGetTexParameteriv (int target, int pname, IntBuffer params) {
|
||||
GL11.glGetTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public int glGetUniformLocation (int program, String name) {
|
||||
return GL20.glGetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
public void glGetUniformfv (int program, int location, FloatBuffer params) {
|
||||
GL20.glGetUniform(program, location, params);
|
||||
}
|
||||
|
||||
public void glGetUniformiv (int program, int location, IntBuffer params) {
|
||||
GL20.glGetUniform(program, location, params);
|
||||
}
|
||||
|
||||
public void glGetVertexAttribPointerv (int index, int pname, Buffer pointer) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement");
|
||||
}
|
||||
|
||||
public void glGetVertexAttribfv (int index, int pname, FloatBuffer params) {
|
||||
GL20.glGetVertexAttrib(index, pname, params);
|
||||
}
|
||||
|
||||
public void glGetVertexAttribiv (int index, int pname, IntBuffer params) {
|
||||
GL20.glGetVertexAttrib(index, pname, params);
|
||||
}
|
||||
|
||||
public void glHint (int target, int mode) {
|
||||
GL11.glHint(target, mode);
|
||||
}
|
||||
|
||||
public boolean glIsBuffer (int buffer) {
|
||||
return GL15.glIsBuffer(buffer);
|
||||
}
|
||||
|
||||
public boolean glIsEnabled (int cap) {
|
||||
return GL11.glIsEnabled(cap);
|
||||
}
|
||||
|
||||
public boolean glIsFramebuffer (int framebuffer) {
|
||||
return EXTFramebufferObject.glIsFramebufferEXT(framebuffer);
|
||||
}
|
||||
|
||||
public boolean glIsProgram (int program) {
|
||||
return GL20.glIsProgram(program);
|
||||
}
|
||||
|
||||
public boolean glIsRenderbuffer (int renderbuffer) {
|
||||
return EXTFramebufferObject.glIsRenderbufferEXT(renderbuffer);
|
||||
}
|
||||
|
||||
public boolean glIsShader (int shader) {
|
||||
return GL20.glIsShader(shader);
|
||||
}
|
||||
|
||||
public boolean glIsTexture (int texture) {
|
||||
return GL11.glIsTexture(texture);
|
||||
}
|
||||
|
||||
public void glLineWidth (float width) {
|
||||
GL11.glLineWidth(width);
|
||||
}
|
||||
|
||||
public void glLinkProgram (int program) {
|
||||
GL20.glLinkProgram(program);
|
||||
}
|
||||
|
||||
public void glPixelStorei (int pname, int param) {
|
||||
GL11.glPixelStorei(pname, param);
|
||||
}
|
||||
|
||||
public void glPolygonOffset (float factor, float units) {
|
||||
GL11.glPolygonOffset(factor, units);
|
||||
}
|
||||
|
||||
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels) {
|
||||
if (pixels instanceof ByteBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (ByteBuffer)pixels);
|
||||
else if (pixels instanceof ShortBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (ShortBuffer)pixels);
|
||||
else if (pixels instanceof IntBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (IntBuffer)pixels);
|
||||
else if (pixels instanceof FloatBuffer)
|
||||
GL11.glReadPixels(x, y, width, height, format, type, (FloatBuffer)pixels);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use " + pixels.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer or FloatBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glReleaseShaderCompiler () {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
public void glRenderbufferStorage (int target, int internalformat, int width, int height) {
|
||||
EXTFramebufferObject.glRenderbufferStorageEXT(target, internalformat, width, height);
|
||||
}
|
||||
|
||||
public void glSampleCoverage (float value, boolean invert) {
|
||||
GL13.glSampleCoverage(value, invert);
|
||||
}
|
||||
|
||||
public void glScissor (int x, int y, int width, int height) {
|
||||
GL11.glScissor(x, y, width, height);
|
||||
}
|
||||
|
||||
public void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) {
|
||||
throw new UnsupportedOperationException("unsupported, won't implement");
|
||||
}
|
||||
|
||||
public void glShaderSource (int shader, String string) {
|
||||
GL20.glShaderSource(shader, string);
|
||||
}
|
||||
|
||||
public void glStencilFunc (int func, int ref, int mask) {
|
||||
GL11.glStencilFunc(func, ref, mask);
|
||||
}
|
||||
|
||||
public void glStencilFuncSeparate (int face, int func, int ref, int mask) {
|
||||
GL20.glStencilFuncSeparate(face, func, ref, mask);
|
||||
}
|
||||
|
||||
public void glStencilMask (int mask) {
|
||||
GL11.glStencilMask(mask);
|
||||
}
|
||||
|
||||
public void glStencilMaskSeparate (int face, int mask) {
|
||||
GL20.glStencilMaskSeparate(face, mask);
|
||||
}
|
||||
|
||||
public void glStencilOp (int fail, int zfail, int zpass) {
|
||||
GL11.glStencilOp(fail, zfail, zpass);
|
||||
}
|
||||
|
||||
public void glStencilOpSeparate (int face, int fail, int zfail, int zpass) {
|
||||
GL20.glStencilOpSeparate(face, fail, zfail, zpass);
|
||||
}
|
||||
|
||||
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
|
||||
Buffer pixels) {
|
||||
if (pixels == null)
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ByteBuffer)null);
|
||||
else if (pixels instanceof ByteBuffer)
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ByteBuffer)pixels);
|
||||
else if (pixels instanceof ShortBuffer)
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ShortBuffer)pixels);
|
||||
else if (pixels instanceof IntBuffer)
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (IntBuffer)pixels);
|
||||
else if (pixels instanceof FloatBuffer)
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (FloatBuffer)pixels);
|
||||
else if (pixels instanceof DoubleBuffer)
|
||||
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (DoubleBuffer)pixels);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use " + pixels.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glTexParameterf (int target, int pname, float param) {
|
||||
GL11.glTexParameterf(target, pname, param);
|
||||
}
|
||||
|
||||
public void glTexParameterfv (int target, int pname, FloatBuffer params) {
|
||||
GL11.glTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public void glTexParameteri (int target, int pname, int param) {
|
||||
GL11.glTexParameteri(target, pname, param);
|
||||
}
|
||||
|
||||
public void glTexParameteriv (int target, int pname, IntBuffer params) {
|
||||
GL11.glTexParameter(target, pname, params);
|
||||
}
|
||||
|
||||
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
|
||||
Buffer pixels) {
|
||||
if (pixels instanceof ByteBuffer)
|
||||
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ByteBuffer)pixels);
|
||||
else if (pixels instanceof ShortBuffer)
|
||||
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ShortBuffer)pixels);
|
||||
else if (pixels instanceof IntBuffer)
|
||||
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (IntBuffer)pixels);
|
||||
else if (pixels instanceof FloatBuffer)
|
||||
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (FloatBuffer)pixels);
|
||||
else if (pixels instanceof DoubleBuffer)
|
||||
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (DoubleBuffer)pixels);
|
||||
else
|
||||
throw new GdxRuntimeException("Can't use " + pixels.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glUniform1f (int location, float x) {
|
||||
GL20.glUniform1f(location, x);
|
||||
}
|
||||
|
||||
public void glUniform1fv (int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform1(location, v);
|
||||
}
|
||||
|
||||
public void glUniform1i (int location, int x) {
|
||||
GL20.glUniform1i(location, x);
|
||||
}
|
||||
|
||||
public void glUniform1iv (int location, int count, IntBuffer v) {
|
||||
GL20.glUniform1(location, v);
|
||||
}
|
||||
|
||||
public void glUniform2f (int location, float x, float y) {
|
||||
GL20.glUniform2f(location, x, y);
|
||||
}
|
||||
|
||||
public void glUniform2fv (int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform2(location, v);
|
||||
}
|
||||
|
||||
public void glUniform2i (int location, int x, int y) {
|
||||
GL20.glUniform2i(location, x, y);
|
||||
}
|
||||
|
||||
public void glUniform2iv (int location, int count, IntBuffer v) {
|
||||
GL20.glUniform2(location, v);
|
||||
}
|
||||
|
||||
public void glUniform3f (int location, float x, float y, float z) {
|
||||
GL20.glUniform3f(location, x, y, z);
|
||||
}
|
||||
|
||||
public void glUniform3fv (int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform3(location, v);
|
||||
}
|
||||
|
||||
public void glUniform3i (int location, int x, int y, int z) {
|
||||
GL20.glUniform3i(location, x, y, z);
|
||||
}
|
||||
|
||||
public void glUniform3iv (int location, int count, IntBuffer v) {
|
||||
GL20.glUniform3(location, v);
|
||||
}
|
||||
|
||||
public void glUniform4f (int location, float x, float y, float z, float w) {
|
||||
GL20.glUniform4f(location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void glUniform4fv (int location, int count, FloatBuffer v) {
|
||||
GL20.glUniform4(location, v);
|
||||
}
|
||||
|
||||
public void glUniform4i (int location, int x, int y, int z, int w) {
|
||||
GL20.glUniform4i(location, x, y, z, w);
|
||||
}
|
||||
|
||||
public void glUniform4iv (int location, int count, IntBuffer v) {
|
||||
GL20.glUniform4(location, v);
|
||||
}
|
||||
|
||||
public void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix2(location, transpose, value);
|
||||
}
|
||||
|
||||
public void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix3(location, transpose, value);
|
||||
}
|
||||
|
||||
public void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value) {
|
||||
GL20.glUniformMatrix4(location, transpose, value);
|
||||
}
|
||||
|
||||
public void glUseProgram (int program) {
|
||||
GL20.glUseProgram(program);
|
||||
}
|
||||
|
||||
public void glValidateProgram (int program) {
|
||||
GL20.glValidateProgram(program);
|
||||
}
|
||||
|
||||
public void glVertexAttrib1f (int indx, float x) {
|
||||
GL20.glVertexAttrib1f(indx, x);
|
||||
}
|
||||
|
||||
public void glVertexAttrib1fv (int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib1f(indx, values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttrib2f (int indx, float x, float y) {
|
||||
GL20.glVertexAttrib2f(indx, x, y);
|
||||
}
|
||||
|
||||
public void glVertexAttrib2fv (int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib2f(indx, values.get(), values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttrib3f (int indx, float x, float y, float z) {
|
||||
GL20.glVertexAttrib3f(indx, x, y, z);
|
||||
}
|
||||
|
||||
public void glVertexAttrib3fv (int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib3f(indx, values.get(), values.get(), values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttrib4f (int indx, float x, float y, float z, float w) {
|
||||
GL20.glVertexAttrib4f(indx, x, y, z, w);
|
||||
}
|
||||
|
||||
public void glVertexAttrib4fv (int indx, FloatBuffer values) {
|
||||
GL20.glVertexAttrib4f(indx, values.get(), values.get(), values.get(), values.get());
|
||||
}
|
||||
|
||||
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer buffer) {
|
||||
if (buffer instanceof ByteBuffer) {
|
||||
if (type == GL_BYTE)
|
||||
GL20.glVertexAttribPointer(indx, size, false, normalized, stride, (ByteBuffer)buffer);
|
||||
else if (type == GL_UNSIGNED_BYTE)
|
||||
GL20.glVertexAttribPointer(indx, size, true, normalized, stride, (ByteBuffer)buffer);
|
||||
else if (type == GL_SHORT)
|
||||
GL20.glVertexAttribPointer(indx, size, false, normalized, stride, ((ByteBuffer)buffer).asShortBuffer());
|
||||
else if (type == GL_UNSIGNED_SHORT)
|
||||
GL20.glVertexAttribPointer(indx, size, true, normalized, stride, ((ByteBuffer)buffer).asShortBuffer());
|
||||
else if (type == GL_FLOAT)
|
||||
GL20.glVertexAttribPointer(indx, size, normalized, stride, ((ByteBuffer)buffer).asFloatBuffer());
|
||||
else
|
||||
throw new GdxRuntimeException(
|
||||
"Can't use "
|
||||
+ buffer.getClass().getName()
|
||||
+ " with type "
|
||||
+ type
|
||||
+ " with this method. Use ByteBuffer and one of GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT or GL_FLOAT for type. Blame LWJGL");
|
||||
} else
|
||||
throw new GdxRuntimeException("Can't use " + buffer.getClass().getName()
|
||||
+ " with this method. Use ByteBuffer instead. Blame LWJGL");
|
||||
}
|
||||
|
||||
public void glViewport (int x, int y, int width, int height) {
|
||||
GL11.glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
public void glDrawElements (int mode, int count, int type, int indices) {
|
||||
GL11.glDrawElements(mode, count, type, indices);
|
||||
}
|
||||
|
||||
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr) {
|
||||
GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ public class GdxMapApp extends GdxMap {
|
||||
// set our globals
|
||||
new SharedLibraryLoader().load("vtm-jni");
|
||||
CanvasAdapter.g = AwtGraphics.INSTANCE;
|
||||
GLAdapter.g = new GdxGLAdapter();
|
||||
GLAdapter.g = new GdxGL20();
|
||||
GLAdapter.GDX_DESKTOP_QUIRKS = true;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ public class GwtBitmap implements Bitmap {
|
||||
Pixmap pixmap;
|
||||
Image image;
|
||||
boolean disposable;
|
||||
|
||||
public GwtBitmap(Image data) {
|
||||
ImageElement imageElement = ImageElement.as(data.getElement());
|
||||
pixmap = new Pixmap(imageElement);
|
||||
@ -63,7 +64,6 @@ public class GwtBitmap implements Bitmap {
|
||||
pixmap.getHeight(), 0,
|
||||
pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
|
||||
|
||||
|
||||
if (disposable || image != null) {
|
||||
Log.d("", "dispose pixmap " + getWidth() + "/" + getHeight());
|
||||
pixmap.dispose();
|
||||
|
@ -19,8 +19,8 @@ public class GwtLauncher extends GwtApplication {
|
||||
|
||||
@Override
|
||||
public GwtApplicationConfiguration getConfig() {
|
||||
GwtApplicationConfiguration cfg = new GwtApplicationConfiguration(
|
||||
GwtGraphics.getWindowWidthJSNI(),
|
||||
GwtApplicationConfiguration cfg =
|
||||
new GwtApplicationConfiguration(GwtGraphics.getWindowWidthJSNI(),
|
||||
GwtGraphics.getWindowHeightJSNI());
|
||||
|
||||
DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
|
||||
|
@ -34,4 +34,3 @@ class MapConfig extends JavaScriptObject {
|
||||
return this.background;
|
||||
}-*/;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,8 @@ public class SearchBox {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final native String getId() /*-{
|
||||
public final native String getId()
|
||||
/*-{
|
||||
return this.osm_id;
|
||||
}-*/;
|
||||
|
||||
|
@ -7,5 +7,4 @@ public class MalformedURLException extends Exception {
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
|
||||
public class GLMatrix {
|
||||
|
||||
public static final int M00 = 0;// 0;
|
||||
@ -41,20 +40,26 @@ public class GLMatrix {
|
||||
public static final int M32 = 11;// 14;
|
||||
public static final int M33 = 15;// 15;
|
||||
|
||||
private final FloatBuffer buffer = ByteBuffer.allocateDirect(16 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer();
|
||||
|
||||
private final FloatBuffer buffer = ByteBuffer.allocateDirect(16 * 4)
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.asFloatBuffer();
|
||||
|
||||
private final static String INVALID_INPUT = "Bad Array!";
|
||||
|
||||
public final float tmp[] = new float[16];
|
||||
public final float val[] = new float[16];
|
||||
|
||||
/** Sets the matrix to the given matrix as a float array. The float array must have at least 16 elements; the first 16 will be
|
||||
/**
|
||||
* Sets the matrix to the given matrix as a float array. The float array
|
||||
* must have at least 16 elements; the first 16 will be
|
||||
* copied.
|
||||
*
|
||||
* @param values The matrix, in float form, that is to be copied. Remember that this matrix is in <a
|
||||
* href="http://en.wikipedia.org/wiki/Row-major_order">column major</a> order.
|
||||
* @return This matrix for the purpose of chaining methods together. */
|
||||
* @param values The matrix, in float form, that is to be copied. Remember
|
||||
* that this matrix is in <a
|
||||
* href="http://en.wikipedia.org/wiki/Row-major_order">column
|
||||
* major</a> order.
|
||||
* @return This matrix for the purpose of chaining methods together.
|
||||
*/
|
||||
public void set(float[] values) {
|
||||
val[M00] = values[M00];
|
||||
val[M10] = values[M10];
|
||||
@ -73,6 +78,7 @@ public class GLMatrix {
|
||||
val[M23] = values[M23];
|
||||
val[M33] = values[M33];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Matrix as float array
|
||||
*
|
||||
@ -258,7 +264,9 @@ public class GLMatrix {
|
||||
public void setValue(int pos, float value) {
|
||||
val[pos] = value;
|
||||
}
|
||||
|
||||
static float PiTimesThumb = 1.0f / (1 << 11);
|
||||
|
||||
/**
|
||||
* add some offset (similar to glDepthOffset)
|
||||
*
|
||||
@ -292,22 +300,38 @@ public class GLMatrix {
|
||||
|
||||
static void matrix4_mul(float[] mata, float[] matb) {
|
||||
float tmp[] = new float[16];
|
||||
tmp[M00] = mata[M00] * matb[M00] + mata[M01] * matb[M10] + mata[M02] * matb[M20] + mata[M03] * matb[M30];
|
||||
tmp[M01] = mata[M00] * matb[M01] + mata[M01] * matb[M11] + mata[M02] * matb[M21] + mata[M03] * matb[M31];
|
||||
tmp[M02] = mata[M00] * matb[M02] + mata[M01] * matb[M12] + mata[M02] * matb[M22] + mata[M03] * matb[M32];
|
||||
tmp[M03] = mata[M00] * matb[M03] + mata[M01] * matb[M13] + mata[M02] * matb[M23] + mata[M03] * matb[M33];
|
||||
tmp[M10] = mata[M10] * matb[M00] + mata[M11] * matb[M10] + mata[M12] * matb[M20] + mata[M13] * matb[M30];
|
||||
tmp[M11] = mata[M10] * matb[M01] + mata[M11] * matb[M11] + mata[M12] * matb[M21] + mata[M13] * matb[M31];
|
||||
tmp[M12] = mata[M10] * matb[M02] + mata[M11] * matb[M12] + mata[M12] * matb[M22] + mata[M13] * matb[M32];
|
||||
tmp[M13] = mata[M10] * matb[M03] + mata[M11] * matb[M13] + mata[M12] * matb[M23] + mata[M13] * matb[M33];
|
||||
tmp[M20] = mata[M20] * matb[M00] + mata[M21] * matb[M10] + mata[M22] * matb[M20] + mata[M23] * matb[M30];
|
||||
tmp[M21] = mata[M20] * matb[M01] + mata[M21] * matb[M11] + mata[M22] * matb[M21] + mata[M23] * matb[M31];
|
||||
tmp[M22] = mata[M20] * matb[M02] + mata[M21] * matb[M12] + mata[M22] * matb[M22] + mata[M23] * matb[M32];
|
||||
tmp[M23] = mata[M20] * matb[M03] + mata[M21] * matb[M13] + mata[M22] * matb[M23] + mata[M23] * matb[M33];
|
||||
tmp[M30] = mata[M30] * matb[M00] + mata[M31] * matb[M10] + mata[M32] * matb[M20] + mata[M33] * matb[M30];
|
||||
tmp[M31] = mata[M30] * matb[M01] + mata[M31] * matb[M11] + mata[M32] * matb[M21] + mata[M33] * matb[M31];
|
||||
tmp[M32] = mata[M30] * matb[M02] + mata[M31] * matb[M12] + mata[M32] * matb[M22] + mata[M33] * matb[M32];
|
||||
tmp[M33] = mata[M30] * matb[M03] + mata[M31] * matb[M13] + mata[M32] * matb[M23] + mata[M33] * matb[M33];
|
||||
tmp[M00] = mata[M00] * matb[M00] + mata[M01] * matb[M10] + mata[M02] * matb[M20]
|
||||
+ mata[M03] * matb[M30];
|
||||
tmp[M01] = mata[M00] * matb[M01] + mata[M01] * matb[M11] + mata[M02] * matb[M21]
|
||||
+ mata[M03] * matb[M31];
|
||||
tmp[M02] = mata[M00] * matb[M02] + mata[M01] * matb[M12] + mata[M02] * matb[M22]
|
||||
+ mata[M03] * matb[M32];
|
||||
tmp[M03] = mata[M00] * matb[M03] + mata[M01] * matb[M13] + mata[M02] * matb[M23]
|
||||
+ mata[M03] * matb[M33];
|
||||
tmp[M10] = mata[M10] * matb[M00] + mata[M11] * matb[M10] + mata[M12] * matb[M20]
|
||||
+ mata[M13] * matb[M30];
|
||||
tmp[M11] = mata[M10] * matb[M01] + mata[M11] * matb[M11] + mata[M12] * matb[M21]
|
||||
+ mata[M13] * matb[M31];
|
||||
tmp[M12] = mata[M10] * matb[M02] + mata[M11] * matb[M12] + mata[M12] * matb[M22]
|
||||
+ mata[M13] * matb[M32];
|
||||
tmp[M13] = mata[M10] * matb[M03] + mata[M11] * matb[M13] + mata[M12] * matb[M23]
|
||||
+ mata[M13] * matb[M33];
|
||||
tmp[M20] = mata[M20] * matb[M00] + mata[M21] * matb[M10] + mata[M22] * matb[M20]
|
||||
+ mata[M23] * matb[M30];
|
||||
tmp[M21] = mata[M20] * matb[M01] + mata[M21] * matb[M11] + mata[M22] * matb[M21]
|
||||
+ mata[M23] * matb[M31];
|
||||
tmp[M22] = mata[M20] * matb[M02] + mata[M21] * matb[M12] + mata[M22] * matb[M22]
|
||||
+ mata[M23] * matb[M32];
|
||||
tmp[M23] = mata[M20] * matb[M03] + mata[M21] * matb[M13] + mata[M22] * matb[M23]
|
||||
+ mata[M23] * matb[M33];
|
||||
tmp[M30] = mata[M30] * matb[M00] + mata[M31] * matb[M10] + mata[M32] * matb[M20]
|
||||
+ mata[M33] * matb[M30];
|
||||
tmp[M31] = mata[M30] * matb[M01] + mata[M31] * matb[M11] + mata[M32] * matb[M21]
|
||||
+ mata[M33] * matb[M31];
|
||||
tmp[M32] = mata[M30] * matb[M02] + mata[M31] * matb[M12] + mata[M32] * matb[M22]
|
||||
+ mata[M33] * matb[M32];
|
||||
tmp[M33] = mata[M30] * matb[M03] + mata[M31] * matb[M13] + mata[M32] * matb[M23]
|
||||
+ mata[M33] * matb[M33];
|
||||
System.arraycopy(tmp, 0, mata, 0, 16);
|
||||
}
|
||||
|
||||
@ -335,6 +359,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Define a projection matrix in terms of six clip planes
|
||||
*
|
||||
* @param m the float array that holds the perspective matrix
|
||||
* @param offset the offset into float array m where the perspective
|
||||
* matrix data is written
|
||||
|
@ -54,6 +54,7 @@ public final class IOUtils {
|
||||
Log.d(IOUtils.class.getName(), e.getMessage() + " " + e);
|
||||
}
|
||||
}
|
||||
|
||||
private IOUtils() {
|
||||
}
|
||||
}
|
||||
|
@ -5,14 +5,16 @@ import com.badlogic.gdx.utils.Disposable;
|
||||
|
||||
/**
|
||||
* GWT emulation of AsynchExecutor, will call tasks immediately :D
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*/
|
||||
public class AsyncExecutor implements Disposable {
|
||||
|
||||
/**
|
||||
* Creates a new AsynchExecutor that allows maxConcurrent
|
||||
* {@link Runnable} instances to run in parallel.
|
||||
* Creates a new AsynchExecutor that allows maxConcurrent {@link Runnable}
|
||||
* instances to run in parallel.
|
||||
*
|
||||
* @param maxConcurrent
|
||||
*/
|
||||
public AsyncExecutor(int maxConcurrent) {
|
||||
@ -23,6 +25,7 @@ public class AsyncExecutor implements Disposable {
|
||||
* Submits a {@link Runnable} to be executed asynchronously. If
|
||||
* maxConcurrent runnables are already running, the runnable
|
||||
* will be queued.
|
||||
*
|
||||
* @param task the task to execute asynchronously
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@ -46,11 +49,13 @@ public class AsyncExecutor implements Disposable {
|
||||
* Submits a {@link Runnable} to be executed asynchronously. If
|
||||
* maxConcurrent runnables are already running, the runnable
|
||||
* will be queued.
|
||||
*
|
||||
* @param task the task to execute asynchronously
|
||||
*/
|
||||
public void post(Runnable task) {
|
||||
Gdx.app.postRunnable(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for running {@link AsyncTask} instances to finish,
|
||||
* then destroys any resources like threads. Can not be used
|
||||
|
@ -19,10 +19,10 @@ package org.oscim.utils.async;
|
||||
//import java.util.concurrent.ExecutionException;
|
||||
//import java.util.concurrent.Future;
|
||||
|
||||
|
||||
/**
|
||||
* Returned by {@link AsyncExecutor#submit(AsyncTask)}, allows to poll
|
||||
* for the result of the asynch workload.
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*/
|
||||
@ -41,7 +41,8 @@ public class AsyncResult<T> {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the result, or null if there was an error, no result, or the task is still running
|
||||
* @return the result, or null if there was an error, no result, or the task
|
||||
* is still running
|
||||
*/
|
||||
public T get() {
|
||||
return result;
|
||||
|
@ -16,13 +16,15 @@
|
||||
|
||||
package org.oscim.utils.async;
|
||||
|
||||
|
||||
/**
|
||||
* Task to be submitted to an {@link AsyncExecutor}, returning a result of type T.
|
||||
* Task to be submitted to an {@link AsyncExecutor}, returning a result of type
|
||||
* T.
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*/
|
||||
public interface AsyncTask<T> extends Runnable {
|
||||
public boolean cancel();
|
||||
|
||||
public T getResult() throws Exception;
|
||||
}
|
@ -18,6 +18,7 @@ package org.oscim.utils.async;
|
||||
|
||||
/**
|
||||
* GWT emulation of ThreadUtils, does nothing.
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*/
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.xml.sax;
|
||||
|
||||
|
||||
public abstract interface Attributes {
|
||||
public abstract int getLength();
|
||||
|
||||
|
@ -12,6 +12,7 @@ public class SAXException extends IOException {
|
||||
public SAXException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public SAXException(String str, Throwable throwable)
|
||||
{
|
||||
super(str);
|
||||
|
@ -10,6 +10,7 @@ public class SAXParseException extends SAXException {
|
||||
public SAXParseException(String str) {
|
||||
super(str);
|
||||
}
|
||||
|
||||
public SAXParseException(String str, Throwable throwable)
|
||||
{
|
||||
super(str);
|
||||
|
@ -12,6 +12,7 @@ public class DefaultHandler {
|
||||
public void error(SAXParseException exception) {
|
||||
|
||||
}
|
||||
|
||||
public void warning(SAXParseException exception) {
|
||||
|
||||
}
|
||||
@ -25,5 +26,4 @@ public class DefaultHandler {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -123,17 +123,17 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
mMap.setTheme(InternalRenderTheme.DEFAULT);
|
||||
|
||||
if (buildings)
|
||||
mMap.getLayers().add(
|
||||
new BuildingLayer(mMap, mMapLayer.getTileLayer()));
|
||||
mMap.getLayers()
|
||||
.add(new BuildingLayer(mMap, mMapLayer.getTileLayer()));
|
||||
|
||||
if (labels)
|
||||
mMap.getLayers().add(new LabelLayer(mMap,
|
||||
mMapLayer.getTileLayer()));
|
||||
mMap.getLayers()
|
||||
.add(new LabelLayer(mMap, mMapLayer.getTileLayer()));
|
||||
}
|
||||
|
||||
if (tileGrid)
|
||||
mMap.getLayers().add(new GenericLayer(mMap,
|
||||
new GridRenderer()));
|
||||
mMap.getLayers()
|
||||
.add(new GenericLayer(mMap, new GridRenderer()));
|
||||
}
|
||||
|
||||
// Stage ui;
|
||||
@ -227,7 +227,6 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
public void resume() {
|
||||
}
|
||||
|
||||
|
||||
class TouchHandler implements InputProcessor {
|
||||
|
||||
private Viewport mMapPosition;
|
||||
@ -533,8 +532,7 @@ public abstract class GdxMap implements ApplicationListener {
|
||||
// decrease change of scale by the change of rotation
|
||||
// * 20 is just arbitrary
|
||||
if (mBeginRotate)
|
||||
scale = 1 + ((scale - 1) * Math.max(
|
||||
(1 - (float) Math.abs(r) * 20), 0));
|
||||
scale = 1 + ((scale - 1) * Math.max((1 - (float) Math.abs(r) * 20), 0));
|
||||
|
||||
mSumScale *= scale;
|
||||
|
||||
|
@ -20,8 +20,11 @@ import java.nio.Buffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
/** Interface wrapping all the methods of OpenGL ES 2.0
|
||||
* @author mzechner */
|
||||
/**
|
||||
* Interface wrapping all the methods of OpenGL ES 2.0
|
||||
*
|
||||
* @author mzechner
|
||||
*/
|
||||
public interface GL20 {
|
||||
public static final int GL_ES_VERSION_2_0 = 1;
|
||||
public static final int GL_DEPTH_BUFFER_BIT = 0x00000100;
|
||||
@ -380,9 +383,11 @@ public interface GL20 {
|
||||
|
||||
public void glEnableVertexAttribArray(int index);
|
||||
|
||||
public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer);
|
||||
public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget,
|
||||
int renderbuffer);
|
||||
|
||||
public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level);
|
||||
public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture,
|
||||
int level);
|
||||
|
||||
public void glGenBuffers(int n, IntBuffer buffers);
|
||||
|
||||
@ -408,7 +413,8 @@ public interface GL20 {
|
||||
|
||||
public void glGetFloatv(int pname, FloatBuffer params);
|
||||
|
||||
public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params);
|
||||
public void glGetFramebufferAttachmentParameteriv(int target, int attachment, int pname,
|
||||
IntBuffer params);
|
||||
|
||||
public void glGetProgramiv(int program, int pname, IntBuffer params);
|
||||
|
||||
@ -422,7 +428,8 @@ public interface GL20 {
|
||||
// deviates
|
||||
public String glGetShaderInfoLog(int shader);
|
||||
|
||||
public void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision);
|
||||
public void glGetShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range,
|
||||
IntBuffer precision);
|
||||
|
||||
public void glGetShaderSource(int shader, int bufsize, Buffer length, String source);
|
||||
|
||||
@ -539,10 +546,11 @@ public interface GL20 {
|
||||
|
||||
public void glVertexAttrib4fv(int indx, FloatBuffer values);
|
||||
|
||||
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer ptr);
|
||||
|
||||
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr);
|
||||
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
|
||||
Buffer ptr);
|
||||
|
||||
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
|
||||
int ptr);
|
||||
|
||||
//------------------------
|
||||
|
||||
@ -566,15 +574,19 @@ public interface GL20 {
|
||||
|
||||
public void glColorMask(boolean red, boolean green, boolean blue, boolean alpha);
|
||||
|
||||
public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border,
|
||||
public void glCompressedTexImage2D(int target, int level, int internalformat, int width,
|
||||
int height, int border,
|
||||
int imageSize, Buffer data);
|
||||
|
||||
public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format,
|
||||
public void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset,
|
||||
int width, int height, int format,
|
||||
int imageSize, Buffer data);
|
||||
|
||||
public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border);
|
||||
public void glCopyTexImage2D(int target, int level, int internalformat, int x, int y,
|
||||
int width, int height, int border);
|
||||
|
||||
public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height);
|
||||
public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
|
||||
int width, int height);
|
||||
|
||||
public void glCullFace(int mode);
|
||||
|
||||
@ -616,7 +628,8 @@ public interface GL20 {
|
||||
|
||||
public void glPolygonOffset(float factor, float units);
|
||||
|
||||
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels);
|
||||
public void glReadPixels(int x, int y, int width, int height, int format, int type,
|
||||
Buffer pixels);
|
||||
|
||||
public void glScissor(int x, int y, int width, int height);
|
||||
|
||||
@ -626,12 +639,14 @@ public interface GL20 {
|
||||
|
||||
public void glStencilOp(int fail, int zfail, int zpass);
|
||||
|
||||
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
|
||||
public void glTexImage2D(int target, int level, int internalformat, int width, int height,
|
||||
int border, int format, int type,
|
||||
Buffer pixels);
|
||||
|
||||
public void glTexParameterf(int target, int pname, float param);
|
||||
|
||||
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
|
||||
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width,
|
||||
int height, int format, int type,
|
||||
Buffer pixels);
|
||||
|
||||
public void glViewport(int x, int y, int width, int height);
|
||||
|
@ -108,7 +108,8 @@ public final class MercatorProjection {
|
||||
out[pos * 2] = ((p.longitudeE6 / 1E6) + 180.0) / 360.0;
|
||||
|
||||
double sinLatitude = Math.sin((p.latitudeE6 / 1E6) * (Math.PI / 180.0));
|
||||
out[pos * 2 +1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Math.PI);
|
||||
out[pos * 2 + 1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude))
|
||||
/ (4.0 * Math.PI);
|
||||
}
|
||||
|
||||
public static void project(double latitude, double longitude, double[] out, int pos) {
|
||||
@ -116,7 +117,8 @@ public final class MercatorProjection {
|
||||
out[pos * 2] = (longitude + 180.0) / 360.0;
|
||||
|
||||
double sinLatitude = Math.sin(latitude * (Math.PI / 180.0));
|
||||
out[pos * 2 +1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Math.PI);
|
||||
out[pos * 2 + 1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude))
|
||||
/ (4.0 * Math.PI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,15 +17,19 @@ package org.oscim.core;
|
||||
public class Point {
|
||||
public double x;
|
||||
public double y;
|
||||
|
||||
public Point() {
|
||||
}
|
||||
|
||||
public Point(double x, double y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ package org.oscim.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
public class TagSet {
|
||||
public static TagSet EMPTY_TAG_SET = new TagSet();
|
||||
|
||||
@ -37,6 +36,7 @@ public class TagSet {
|
||||
|
||||
/**
|
||||
* null out current tags
|
||||
*
|
||||
* @param nulltags ...
|
||||
*/
|
||||
public void clear(boolean nulltags) {
|
||||
@ -58,6 +58,7 @@ public class TagSet {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean containsKey(String key) {
|
||||
for (int i = 0; i < numTags; i++) {
|
||||
if (tags[i].key == key)
|
||||
|
@ -3,5 +3,6 @@ package org.oscim.event;
|
||||
public interface EventDispatcher {
|
||||
|
||||
public void addListener(String type, EventListener listener);
|
||||
|
||||
public void removeListener(String type, EventListener listener);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ public class MapEvent extends EventObject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public MapEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
package org.oscim.event;
|
||||
|
||||
|
||||
public abstract class MotionEvent extends MapEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -4,6 +4,8 @@ import org.oscim.core.MapPosition;
|
||||
|
||||
public interface TouchListener {
|
||||
boolean onPress(MotionEvent e, MapPosition pos);
|
||||
|
||||
boolean onLongPress(MotionEvent e, MapPosition pos);
|
||||
|
||||
boolean onTap(MotionEvent e, MapPosition pos);
|
||||
}
|
||||
|
@ -3,16 +3,16 @@ package org.oscim.layers;
|
||||
import org.oscim.backend.Log;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.map.Map;
|
||||
import org.oscim.map.Map.UpdateListener;
|
||||
import org.oscim.renderer.LayerRenderer;
|
||||
import org.oscim.renderer.MapRenderer.Matrices;
|
||||
|
||||
public class CustomRenderLayer extends Layer {
|
||||
public class CustomRenderLayer extends Layer implements UpdateListener {
|
||||
|
||||
private static final String TAG = CustomRenderLayer.class.getName();
|
||||
|
||||
class CustomRenderer extends LayerRenderer {
|
||||
|
||||
|
||||
// functions running on MapRender Thread
|
||||
@Override
|
||||
protected void update(MapPosition pos, boolean changed, Matrices matrices) {
|
||||
@ -33,7 +33,6 @@ public class CustomRenderLayer extends Layer {
|
||||
@Override
|
||||
protected void render(MapPosition pos, Matrices m) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CustomRenderLayer(Map map, LayerRenderer renderer) {
|
||||
@ -44,14 +43,11 @@ public class CustomRenderLayer extends Layer {
|
||||
|
||||
private int someConccurentVariable;
|
||||
|
||||
// @Override
|
||||
// public void onUpdate(MapPosition mapPosition, boolean changed, boolean clear) {
|
||||
//
|
||||
// synchronized (mRenderer) {
|
||||
// // chang
|
||||
// someConccurentVariable++;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
@Override
|
||||
public void onMapUpdate(MapPosition mapPosition, boolean changed, boolean clear) {
|
||||
|
||||
synchronized (mRenderer) {
|
||||
someConccurentVariable++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ public class MapEventLayer extends Layer implements EventListener {
|
||||
if (event instanceof MotionEvent)
|
||||
onTouchEvent((MotionEvent) event);
|
||||
}
|
||||
|
||||
//private long mPrevTime;
|
||||
|
||||
private boolean mEnableRotation = true;
|
||||
@ -312,8 +313,7 @@ public class MapEventLayer extends Layer implements EventListener {
|
||||
int w = Tile.SIZE * 3;
|
||||
int h = Tile.SIZE * 3;
|
||||
|
||||
mMap.getAnimator().animateFling(
|
||||
Math.round(velocityX),
|
||||
mMap.getAnimator().animateFling(Math.round(velocityX),
|
||||
Math.round(velocityY),
|
||||
-w, w, -h, h);
|
||||
return true;
|
||||
|
@ -295,7 +295,8 @@ public class PathLayer extends Layer {
|
||||
* Math.pow(Math.sin((lon1 - lon2) / 2), 2)));
|
||||
double bearing = Math.atan2(
|
||||
Math.sin(lon1 - lon2) * Math.cos(lat2),
|
||||
Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2)
|
||||
Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
|
||||
* Math.cos(lat2)
|
||||
* Math.cos(lon1 - lon2))
|
||||
/ -(Math.PI / 180);
|
||||
bearing = bearing < 0 ? 360 + bearing : bearing;
|
||||
|
@ -157,6 +157,7 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
|
||||
* When a content sensitive action is performed the content item needs to be
|
||||
* identified. This method does that and then performs the assigned task on
|
||||
* that item.
|
||||
*
|
||||
* @param event
|
||||
* ...
|
||||
* @param task
|
||||
@ -218,6 +219,7 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
|
||||
* When the item is touched one of these methods may be invoked depending on
|
||||
* the type of touch. Each of them returns true if the event was completely
|
||||
* handled.
|
||||
*
|
||||
* @param <T>
|
||||
* ....
|
||||
*/
|
||||
|
@ -20,8 +20,10 @@ import java.net.URL;
|
||||
import org.oscim.core.Tile;
|
||||
//http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/5/14/14
|
||||
//http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer
|
||||
|
||||
public class ArcGISWorldShaded extends AbstractTileSource {
|
||||
public static final ArcGISWorldShaded INSTANCE = new ArcGISWorldShaded("server.arcgisonline.com", 80);
|
||||
public static final ArcGISWorldShaded INSTANCE = new ArcGISWorldShaded("server.arcgisonline.com",
|
||||
80);
|
||||
private static final int PARALLEL_REQUESTS_LIMIT = 4;
|
||||
private static final String PROTOCOL = "http";
|
||||
private static final int ZOOM_LEVEL_MAX = 6;
|
||||
|
@ -34,7 +34,6 @@ import org.oscim.tiling.TileLoader;
|
||||
import org.oscim.tiling.TileManager;
|
||||
import org.oscim.utils.FastMath;
|
||||
|
||||
|
||||
public class BitmapTileLayer extends TileLayer<TileLoader> {
|
||||
private static final int TIMEOUT_CONNECT = 5000;
|
||||
private static final int TIMEOUT_READ = 10000;
|
||||
@ -50,7 +49,6 @@ public class BitmapTileLayer extends TileLayer<TileLoader> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMapUpdate(MapPosition pos, boolean changed, boolean clear) {
|
||||
super.onMapUpdate(pos, changed, clear);
|
||||
|
@ -21,7 +21,8 @@ import org.oscim.core.Tile;
|
||||
|
||||
public interface TileSource {
|
||||
/**
|
||||
* @return the maximum number of parallel requests which this {@code TileSource} supports.
|
||||
* @return the maximum number of parallel requests which this
|
||||
* {@code TileSource} supports.
|
||||
*/
|
||||
int getParallelRequestsLimit();
|
||||
|
||||
|
@ -54,7 +54,6 @@ class Label extends TextItem {
|
||||
|
||||
static int comparePriority(Label l1, Label l2) {
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -128,6 +128,7 @@ public abstract class Map implements EventDispatcher {
|
||||
* Request call to onUpdate for all layers. This function can
|
||||
* be called from any thread. Request will be handled on main
|
||||
* thread.
|
||||
*
|
||||
* @param forceRedraw pass true to render next frame
|
||||
*/
|
||||
public abstract void updateMap(boolean forceRedraw);
|
||||
@ -192,6 +193,7 @@ public abstract class Map implements EventDispatcher {
|
||||
|
||||
/**
|
||||
* Get current {@link MapPosition}.
|
||||
*
|
||||
* @param mapPosition
|
||||
*/
|
||||
public boolean getMapPosition(MapPosition mapPosition) {
|
||||
|
@ -195,7 +195,6 @@ public final class BufferObject {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static synchronized void clear() {
|
||||
mBufferMemoryUsage = 0;
|
||||
|
||||
|
@ -228,6 +228,7 @@ public class GLMatrix {
|
||||
|
||||
/**
|
||||
* Define a projection matrix in terms of six clip planes
|
||||
*
|
||||
* @param m the float array that holds the perspective matrix
|
||||
* @param offset the offset into float array m where the perspective
|
||||
* matrix data is written
|
||||
|
@ -62,11 +62,13 @@ public class GLUtils {
|
||||
public static void setColorBlend(int location, int color1, int color2, float mix) {
|
||||
float a1 = (((color1 >>> 24) & 0xff) / 255f) * (1 - mix);
|
||||
float a2 = (((color2 >>> 24) & 0xff) / 255f) * mix;
|
||||
GL.glUniform4f
|
||||
(location,
|
||||
((((color1 >>> 16) & 0xff) / 255f) * a1 + (((color2 >>> 16) & 0xff) / 255f) * a2),
|
||||
((((color1 >>> 8) & 0xff) / 255f) * a1 + (((color2 >>> 8) & 0xff) / 255f) * a2),
|
||||
((((color1 >>> 0) & 0xff) / 255f) * a1 + (((color2 >>> 0) & 0xff) / 255f) * a2),
|
||||
GL.glUniform4f(location,
|
||||
((((color1 >>> 16) & 0xff) / 255f) * a1
|
||||
+ (((color2 >>> 16) & 0xff) / 255f) * a2),
|
||||
((((color1 >>> 8) & 0xff) / 255f) * a1
|
||||
+ (((color2 >>> 8) & 0xff) / 255f) * a2),
|
||||
((((color1 >>> 0) & 0xff) / 255f) * a1
|
||||
+ (((color2 >>> 0) & 0xff) / 255f) * a2),
|
||||
(a1 + a2));
|
||||
}
|
||||
|
||||
@ -133,7 +135,8 @@ public class GLUtils {
|
||||
return loadTexture(pixel, sum, 1, GL20.GL_ALPHA,
|
||||
GL20.GL_LINEAR, GL20.GL_LINEAR,
|
||||
// GLES20.GL_NEAREST, GLES20.GL_NEAREST,
|
||||
GL20.GL_REPEAT, GL20.GL_REPEAT);
|
||||
GL20.GL_REPEAT,
|
||||
GL20.GL_REPEAT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,9 +20,6 @@ import org.oscim.renderer.atlas.TextureAtlas.Rect;
|
||||
import org.oscim.renderer.elements.TextureItem;
|
||||
import org.oscim.utils.pool.Inlist;
|
||||
|
||||
|
||||
|
||||
|
||||
public abstract class SpriteManager<T> {
|
||||
|
||||
public class Sprite extends Inlist<Sprite> {
|
||||
|
@ -66,7 +66,6 @@ import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.renderer.elements.TextureItem;
|
||||
import org.oscim.utils.pool.Inlist;
|
||||
|
||||
|
||||
public class TextureAtlas extends Inlist<TextureAtlas> {
|
||||
private final static String TAG = TextureAtlas.class.getName();
|
||||
|
||||
@ -86,7 +85,6 @@ public class TextureAtlas extends Inlist<TextureAtlas> {
|
||||
/** Allocated surface size */
|
||||
int mUsed;
|
||||
|
||||
|
||||
public TextureItem texture;
|
||||
|
||||
/**
|
||||
|
@ -506,7 +506,8 @@ public final class LineTexLayer extends RenderElement {
|
||||
+ " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
|
||||
+ " } "; //*/
|
||||
|
||||
/* final static String fragmentShader = ""
|
||||
/*
|
||||
* final static String fragmentShader = ""
|
||||
* + "#extension GL_OES_standard_derivatives : enable\n"
|
||||
* + " precision mediump float;"
|
||||
* + " uniform sampler2D tex;"
|
||||
@ -527,8 +528,10 @@ public final class LineTexLayer extends RenderElement {
|
||||
* + " gl_FragColor = u_bgcolor * stipple_p;"
|
||||
* // +
|
||||
* " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
|
||||
* + "}"; // */
|
||||
/* final static String fragmentShader = ""
|
||||
* + "}"; //
|
||||
*/
|
||||
/*
|
||||
* final static String fragmentShader = ""
|
||||
* + "#extension GL_OES_standard_derivatives : enable\n"
|
||||
* + " precision mediump float;"
|
||||
* + " uniform sampler2D tex;"
|
||||
@ -547,7 +550,8 @@ public final class LineTexLayer extends RenderElement {
|
||||
* + " float stipple_p = smoothstep(0.495, 0.505, dist);"
|
||||
* +
|
||||
* " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
|
||||
* + " } "; // */
|
||||
* + " } "; //
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import org.oscim.backend.Log;
|
||||
import org.oscim.core.GeometryBuffer;
|
||||
import org.oscim.core.Tile;
|
||||
|
||||
|
||||
public class MeshLayer extends RenderElement {
|
||||
GeometryBuffer mGeom = new GeometryBuffer(10, 10);
|
||||
|
||||
|
@ -465,7 +465,9 @@ public final class PolygonLayer extends RenderElement {
|
||||
static void debugDraw(GLMatrix m, float[] coords, int color) {
|
||||
GLState.test(false, false);
|
||||
if (mDebugFill == null) {
|
||||
mDebugFill = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder())
|
||||
mDebugFill = ByteBuffer
|
||||
.allocateDirect(32)
|
||||
.order(ByteOrder.nativeOrder())
|
||||
.asFloatBuffer();
|
||||
mDebugFill.put(coords);
|
||||
}
|
||||
|
@ -44,5 +44,6 @@ public abstract class RenderElement extends Inlist<RenderElement>{
|
||||
protected VertexItem curItem;
|
||||
|
||||
abstract protected void compile(ShortBuffer sbuf);
|
||||
|
||||
abstract protected void clear();
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.renderer.atlas.TextureAtlas;
|
||||
import org.oscim.utils.pool.Inlist;
|
||||
|
||||
|
||||
public final class SymbolLayer extends TextureLayer {
|
||||
private final static String TAG = SymbolLayer.class.getName();
|
||||
|
||||
|
@ -36,7 +36,8 @@ public class VertexItem extends Inlist<VertexItem> {
|
||||
};
|
||||
|
||||
/**
|
||||
* Add VertexItems back to pool. Make sure to not use the reference afterwards!
|
||||
* Add VertexItems back to pool. Make sure to not use the reference
|
||||
* afterwards!
|
||||
* i.e.:
|
||||
* vertexItem.release();
|
||||
* vertexItem = null;
|
||||
|
@ -26,7 +26,6 @@ import org.oscim.renderer.GLUtils;
|
||||
import org.oscim.renderer.LayerRenderer;
|
||||
import org.oscim.renderer.MapRenderer.Matrices;
|
||||
|
||||
|
||||
/*
|
||||
* This is an example how to integrate custom OpenGL drawing routines as map overlay
|
||||
*
|
||||
@ -140,7 +139,7 @@ public class CustomRenderer extends LayerRenderer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private final static String vShaderStr =
|
||||
private final static String vShaderStr = "" +
|
||||
"precision mediump float;"
|
||||
+ "uniform mat4 u_mvp;"
|
||||
+ "attribute vec4 a_pos;"
|
||||
@ -151,7 +150,7 @@ public class CustomRenderer extends LayerRenderer {
|
||||
+ " alpha = a_pos.z;"
|
||||
+ "}";
|
||||
|
||||
private final static String fShaderStr =
|
||||
private final static String fShaderStr = "" +
|
||||
"precision mediump float;"
|
||||
+ "varying float alpha;"
|
||||
+ "void main()"
|
||||
|
@ -27,7 +27,6 @@ import org.oscim.renderer.MapRenderer;
|
||||
import org.oscim.renderer.MapRenderer.Matrices;
|
||||
import org.oscim.utils.FastMath;
|
||||
|
||||
|
||||
/*
|
||||
* This is an example how to integrate custom OpenGL drawing routines as map overlay
|
||||
*
|
||||
@ -133,7 +132,10 @@ public class CustomRenderer2 extends ElementRenderer {
|
||||
float fy = (float) (y + offset_y) / (offset_y * 2);
|
||||
float fx = (float) (x + offset_x) / (offset_x * 2);
|
||||
float fz = FastMath.clamp(
|
||||
(float) (x < 0 || y < 0 ? 1 - Math.sqrt(fx * fx + fy * fy) : 0), 0, 1);
|
||||
(float) (x < 0 || y < 0 ? 1 - Math.sqrt(fx * fx + fy * fy)
|
||||
: 0),
|
||||
0,
|
||||
1);
|
||||
|
||||
int c = 0xff << 24
|
||||
| (int) (0xff * fy) << 16
|
||||
@ -183,7 +185,7 @@ public class CustomRenderer2 extends ElementRenderer {
|
||||
return true;
|
||||
}
|
||||
|
||||
private final static String vShaderStr =
|
||||
private final static String vShaderStr = "" +
|
||||
"precision mediump float;"
|
||||
+ "uniform mat4 u_mvp;"
|
||||
+ "uniform vec2 u_center;"
|
||||
@ -193,7 +195,7 @@ public class CustomRenderer2 extends ElementRenderer {
|
||||
+ " gl_Position = u_mvp * vec4(u_center + a_pos, 0.0, 1.0);"
|
||||
+ "}";
|
||||
|
||||
private final static String fShaderStr =
|
||||
private final static String fShaderStr = "" +
|
||||
"precision mediump float;"
|
||||
+ "varying float alpha;"
|
||||
+ "uniform vec4 u_color;"
|
||||
|
@ -35,7 +35,6 @@ public interface IRenderTheme {
|
||||
*/
|
||||
public abstract RenderInstruction[] matchElement(MapElement element, int zoomLevel);
|
||||
|
||||
|
||||
/**
|
||||
* Must be called when this RenderTheme gets destroyed to clean up and free
|
||||
* resources.
|
||||
@ -69,7 +68,6 @@ public interface IRenderTheme {
|
||||
*/
|
||||
public abstract void scaleTextSize(float scaleFactor);
|
||||
|
||||
|
||||
/**
|
||||
* Callback methods for rendering areas, ways and points of interest (POIs).
|
||||
*/
|
||||
|
@ -57,6 +57,7 @@ public class RenderTheme implements IRenderTheme {
|
||||
cacheKey = new MatchingCacheKey();
|
||||
matchType = type;
|
||||
}
|
||||
|
||||
RenderInstructionItem getRenderInstructions() {
|
||||
return cache.get(cacheKey);
|
||||
}
|
||||
|
@ -337,8 +337,7 @@ public class RenderThemeHandler extends DefaultHandler {
|
||||
}
|
||||
}
|
||||
if (img == null)
|
||||
throw new IllegalArgumentException(
|
||||
"missing attribute 'img' for element: "
|
||||
throw new IllegalArgumentException("missing attribute 'img' for element: "
|
||||
+ elementName);
|
||||
|
||||
Bitmap bitmap = CanvasAdapter.g.loadBitmapAsset(IMG_PATH + img);
|
||||
@ -368,8 +367,7 @@ public class RenderThemeHandler extends DefaultHandler {
|
||||
}
|
||||
}
|
||||
if (regionName == null || r == null)
|
||||
throw new IllegalArgumentException(
|
||||
"missing attribute 'name' or 'rect' for element: "
|
||||
throw new IllegalArgumentException("missing attribute 'name' or 'rect' for element: "
|
||||
+ elementName);
|
||||
|
||||
mTextureAtlas.addTextureRegion(regionName.intern(), r);
|
||||
|
@ -36,7 +36,6 @@ public class ThemeLoader {
|
||||
return load((Theme) internalRenderTheme);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load theme from XML file.
|
||||
*
|
||||
|
@ -22,7 +22,6 @@ import org.oscim.theme.IRenderTheme.Callback;
|
||||
*/
|
||||
public final class Area extends RenderInstruction {
|
||||
|
||||
|
||||
public Area(int fill) {
|
||||
this(0, fill);
|
||||
}
|
||||
@ -39,7 +38,6 @@ public final class Area extends RenderInstruction {
|
||||
texture = null;
|
||||
}
|
||||
|
||||
|
||||
public Area(String style, int fill, int stroke, float strokeWidth,
|
||||
int fade, int level, int blend, int blendFill, TextureItem texture) {
|
||||
|
||||
|
@ -16,13 +16,11 @@ package org.oscim.theme.renderinstruction;
|
||||
|
||||
import org.oscim.theme.IRenderTheme.Callback;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a round area on the map.
|
||||
*/
|
||||
public final class Circle extends RenderInstruction {
|
||||
|
||||
|
||||
public final int level;
|
||||
|
||||
public final int fill;
|
||||
|
@ -47,8 +47,6 @@ public final class Line extends RenderInstruction {
|
||||
public final int stippleColor;
|
||||
public final float stippleWidth;
|
||||
|
||||
|
||||
|
||||
public Line(int level, String style, int color, float width,
|
||||
Cap cap, boolean fixed,
|
||||
int stipple, int stippleColor, float stippleWidth,
|
||||
|
@ -27,7 +27,6 @@ import org.oscim.theme.IRenderTheme.Callback;
|
||||
*/
|
||||
public final class Text extends RenderInstruction {
|
||||
|
||||
|
||||
public final String style;
|
||||
|
||||
public final float fontSize;
|
||||
@ -52,12 +51,22 @@ public final class Text extends RenderInstruction {
|
||||
return createText("", fontSize, strokeWidth, fill, outline, billboard);
|
||||
}
|
||||
|
||||
|
||||
public static Text createText(String textKey, float fontSize, float strokeWidth, int fill, int outline,
|
||||
public static Text createText(String textKey, float fontSize, float strokeWidth, int fill,
|
||||
int outline,
|
||||
boolean billboard) {
|
||||
|
||||
Text t = new Text("", textKey, FontFamily.DEFAULT, FontStyle.NORMAL,
|
||||
fontSize, fill, outline, strokeWidth, 0, billboard, null, Integer.MAX_VALUE);
|
||||
Text t = new Text("",
|
||||
textKey,
|
||||
FontFamily.DEFAULT,
|
||||
FontStyle.NORMAL,
|
||||
fontSize,
|
||||
fill,
|
||||
outline,
|
||||
strokeWidth,
|
||||
0,
|
||||
billboard,
|
||||
null,
|
||||
Integer.MAX_VALUE);
|
||||
|
||||
t.fontHeight = t.paint.getFontHeight();
|
||||
t.fontDescent = t.paint.getFontDescent();
|
||||
|
@ -27,8 +27,11 @@ import org.oscim.theme.renderinstruction.RenderInstruction;
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
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_VALUE = 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 Pattern SPLIT_PATTERN = Pattern.compile("\\|");
|
||||
private static final String STRING_NEGATION = "~";
|
||||
private static final String STRING_EXCLUSIVE = "-";
|
||||
@ -132,8 +135,8 @@ public abstract class Rule {
|
||||
throw new IllegalArgumentException("zoom-max must not be negative: "
|
||||
+ zoomMax);
|
||||
} else if (zoomMin > zoomMax) {
|
||||
throw new IllegalArgumentException(
|
||||
"zoom-min must be less or equal zoom-max: " + zoomMin);
|
||||
throw new IllegalArgumentException("zoom-min must be less or equal zoom-max: "
|
||||
+ zoomMin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,8 +99,6 @@ public class TileRenderer extends LayerRenderer {
|
||||
draw(tiles, tileCnt, pos, m);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void clearTiles() {
|
||||
// Clear all references to MapTiles as all current
|
||||
// tiles will also be removed from TileManager.
|
||||
|
@ -48,13 +48,17 @@ public interface ITileCache {
|
||||
|
||||
public interface TileReader {
|
||||
Tile getTile();
|
||||
|
||||
InputStream getInputStream();
|
||||
|
||||
int getBytes();
|
||||
}
|
||||
|
||||
public interface TileWriter {
|
||||
Tile getTile();
|
||||
|
||||
OutputStream getOutputStream();
|
||||
|
||||
void complete(boolean success);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ public interface ITileDataSource {
|
||||
abstract QueryResult executeQuery(MapTile tile,
|
||||
ITileDataSink mapDataSink);
|
||||
|
||||
|
||||
abstract void destroy();
|
||||
|
||||
public static enum QueryResult {
|
||||
|
@ -36,10 +36,14 @@ public abstract class PbfDecoder {
|
||||
}
|
||||
}
|
||||
|
||||
final static ProtobufException TRUNCATED_MSG = new ProtobufException("truncated msg");
|
||||
protected final static ProtobufException INVALID_VARINT = new ProtobufException("invalid varint");
|
||||
protected final static ProtobufException INVALID_PACKED_SIZE = new ProtobufException(
|
||||
"invalid message size");
|
||||
final static ProtobufException TRUNCATED_MSG =
|
||||
new ProtobufException("truncated msg");
|
||||
|
||||
protected final static ProtobufException INVALID_VARINT =
|
||||
new ProtobufException("invalid varint");
|
||||
|
||||
protected final static ProtobufException INVALID_PACKED_SIZE =
|
||||
new ProtobufException("invalid message size");
|
||||
|
||||
protected void error(String msg) throws IOException {
|
||||
throw new ProtobufException(msg);
|
||||
|
@ -35,7 +35,6 @@ public abstract class PbfTileDataSource implements ITileDataSource {
|
||||
protected LwHttp mConn;
|
||||
protected final PbfDecoder mTileDecoder;
|
||||
|
||||
|
||||
public PbfTileDataSource(PbfDecoder tileDecoder) {
|
||||
mTileDecoder = tileDecoder;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import org.oscim.core.Tile;
|
||||
|
||||
public class Projection {
|
||||
|
||||
|
||||
/**
|
||||
* Converts a tile X number at a certain zoom level to a longitude
|
||||
* coordinate.
|
||||
@ -88,6 +87,7 @@ public class Projection {
|
||||
return (int) Math.min(Math.max(pixelX / Tile.SIZE, 0),
|
||||
Math.pow(2, zoomLevel) - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a pixel Y coordinate to the tile Y number.
|
||||
*
|
||||
@ -160,6 +160,7 @@ public class Projection {
|
||||
return (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI))
|
||||
* ((long) Tile.SIZE << zoomLevel);
|
||||
}
|
||||
|
||||
private Projection() {
|
||||
|
||||
}
|
||||
|
@ -108,8 +108,7 @@ public class MapFileHeader {
|
||||
return openResult;
|
||||
}
|
||||
|
||||
openResult = RequiredFields
|
||||
.readFileSize(readBuffer, fileSize, mapFileInfoBuilder);
|
||||
openResult = RequiredFields.readFileSize(readBuffer, fileSize, mapFileInfoBuilder);
|
||||
if (!openResult.isSuccess()) {
|
||||
return openResult;
|
||||
}
|
||||
|
@ -110,7 +110,6 @@ public class SubFileParameter {
|
||||
*/
|
||||
private final int hashCodeValue;
|
||||
|
||||
|
||||
SubFileParameter(SubFileParameterBuilder subFileParameterBuilder) {
|
||||
this.startAddress = subFileParameterBuilder.startAddress;
|
||||
this.indexStartAddress = subFileParameterBuilder.indexStartAddress;
|
||||
@ -123,16 +122,20 @@ public class SubFileParameter {
|
||||
// calculate the XY numbers of the boundary tiles in this sub-file
|
||||
this.boundaryTileBottom = Projection.latitudeToTileY(
|
||||
subFileParameterBuilder.boundingBox.minLatitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
/ COORDINATES_DIVISOR,
|
||||
this.baseZoomLevel);
|
||||
this.boundaryTileLeft = Projection.longitudeToTileX(
|
||||
subFileParameterBuilder.boundingBox.minLongitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
/ COORDINATES_DIVISOR,
|
||||
this.baseZoomLevel);
|
||||
this.boundaryTileTop = Projection.latitudeToTileY(
|
||||
subFileParameterBuilder.boundingBox.maxLatitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
/ COORDINATES_DIVISOR,
|
||||
this.baseZoomLevel);
|
||||
this.boundaryTileRight = Projection.longitudeToTileX(
|
||||
subFileParameterBuilder.boundingBox.maxLongitudeE6
|
||||
/ COORDINATES_DIVISOR, this.baseZoomLevel);
|
||||
/ COORDINATES_DIVISOR,
|
||||
this.baseZoomLevel);
|
||||
|
||||
// calculate the horizontal and vertical amount of blocks in this sub-file
|
||||
this.blocksWidth = this.boundaryTileRight - this.boundaryTileLeft + 1;
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
package org.oscim.tiling.source.mapnik;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
@ -70,7 +69,8 @@ public class TileDecoder extends PbfDecoder {
|
||||
private float mScale;
|
||||
|
||||
@Override
|
||||
public boolean decode(Tile tile, ITileDataSink mapDataCallback, InputStream is, int contentLength)
|
||||
public boolean decode(Tile tile, ITileDataSink mapDataCallback, InputStream is,
|
||||
int contentLength)
|
||||
throws IOException {
|
||||
if (debug)
|
||||
Log.d(TAG, tile + " decode");
|
||||
|
@ -20,6 +20,7 @@ import org.oscim.tiling.source.ITileDataSource;
|
||||
import org.oscim.tiling.source.common.LwHttp;
|
||||
import org.oscim.tiling.source.common.PbfTileDataSource;
|
||||
import org.oscim.tiling.source.common.UrlTileSource;
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
*
|
||||
|
@ -78,9 +78,10 @@ public class TileDecoder extends PbfDecoder {
|
||||
}
|
||||
|
||||
private static final int MAX_TAGS_CACHE = 100;
|
||||
private static Map<String, Tag> tagHash = Collections
|
||||
.synchronizedMap(new LinkedHashMap<String, Tag>(
|
||||
MAX_TAGS_CACHE, 0.75f, true) {
|
||||
private static Map<String, Tag> tagHash =
|
||||
Collections.synchronizedMap(new LinkedHashMap<String, Tag>(MAX_TAGS_CACHE,
|
||||
0.75f,
|
||||
true) {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -312,7 +312,6 @@ public class TileDecoder extends PbfDecoder {
|
||||
mElem.layer = decodeVarint32();
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
Log.d(TAG, mTile + " invalid type for way: " + tag);
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ public class LineClipper {
|
||||
/**
|
||||
* @param x1 ...
|
||||
* @param y1 ...
|
||||
* @return 0 if not intersection, 1 fully within, -1 clipped (and 'out' set to new points)
|
||||
* @return 0 if not intersection, 1 fully within, -1 clipped (and 'out' set
|
||||
* to new points)
|
||||
*/
|
||||
public int clipNext(int x1, int y1) {
|
||||
int accept;
|
||||
|
@ -18,10 +18,13 @@ package org.oscim.utils;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/** Utility and fast math functions.
|
||||
/**
|
||||
* Utility and fast math functions.
|
||||
* <p>
|
||||
* Thanks to Riven on JavaGaming.org for the basis of sin/cos/atan2/floor/ceil.
|
||||
* @author Nathan Sweet */
|
||||
*
|
||||
* @author Nathan Sweet
|
||||
*/
|
||||
public class MathUtils {
|
||||
static public final float nanoToSec = 1 / 1000000000f;
|
||||
|
||||
@ -135,7 +138,10 @@ public class MathUtils {
|
||||
|
||||
static public Random random = new Random();
|
||||
|
||||
/** Returns a random number between 0 (inclusive) and the specified value (inclusive). */
|
||||
/**
|
||||
* Returns a random number between 0 (inclusive) and the specified value
|
||||
* (inclusive).
|
||||
*/
|
||||
static public final int random(int range) {
|
||||
return random.nextInt(range + 1);
|
||||
}
|
||||
@ -155,7 +161,10 @@ public class MathUtils {
|
||||
return random.nextFloat();
|
||||
}
|
||||
|
||||
/** Returns a random number between 0 (inclusive) and the specified value (exclusive). */
|
||||
/**
|
||||
* Returns a random number between 0 (inclusive) and the specified value
|
||||
* (exclusive).
|
||||
*/
|
||||
static public final float random(float range) {
|
||||
return random.nextFloat() * range;
|
||||
}
|
||||
@ -167,9 +176,13 @@ public class MathUtils {
|
||||
|
||||
// ---
|
||||
|
||||
/** Returns the next power of two. Returns the specified value if the value is already a power of two. */
|
||||
/**
|
||||
* Returns the next power of two. Returns the specified value if the value
|
||||
* is already a power of two.
|
||||
*/
|
||||
static public int nextPowerOfTwo(int value) {
|
||||
if (value == 0) return 1;
|
||||
if (value == 0)
|
||||
return 1;
|
||||
value--;
|
||||
value |= value >> 1;
|
||||
value |= value >> 2;
|
||||
@ -186,20 +199,26 @@ public class MathUtils {
|
||||
// ---
|
||||
|
||||
static public int clamp(int value, int min, int max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
if (value < min)
|
||||
return min;
|
||||
if (value > max)
|
||||
return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
static public short clamp(short value, short min, short max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
if (value < min)
|
||||
return min;
|
||||
if (value > max)
|
||||
return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
static public float clamp(float value, float min, float max) {
|
||||
if (value < min) return min;
|
||||
if (value > max) return max;
|
||||
if (value < min)
|
||||
return min;
|
||||
if (value > max)
|
||||
return max;
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -211,37 +230,55 @@ public class MathUtils {
|
||||
static private final double BIG_ENOUGH_CEIL = Double.longBitsToDouble(Double.doubleToLongBits(BIG_ENOUGH_INT + 1) - 1);
|
||||
static private final double BIG_ENOUGH_ROUND = BIG_ENOUGH_INT + 0.5f;
|
||||
|
||||
/** Returns the largest integer less than or equal to the specified float. This method will only properly floor floats from
|
||||
* -(2^14) to (Float.MAX_VALUE - 2^14). */
|
||||
/**
|
||||
* Returns the largest integer less than or equal to the specified float.
|
||||
* This method will only properly floor floats from
|
||||
* -(2^14) to (Float.MAX_VALUE - 2^14).
|
||||
*/
|
||||
static public int floor(float x) {
|
||||
return (int) (x + BIG_ENOUGH_FLOOR) - BIG_ENOUGH_INT;
|
||||
}
|
||||
|
||||
/** Returns the largest integer less than or equal to the specified float. This method will only properly floor floats that are
|
||||
* positive. Note this method simply casts the float to int. */
|
||||
/**
|
||||
* Returns the largest integer less than or equal to the specified float.
|
||||
* This method will only properly floor floats that are
|
||||
* positive. Note this method simply casts the float to int.
|
||||
*/
|
||||
static public int floorPositive(float x) {
|
||||
return (int) x;
|
||||
}
|
||||
|
||||
/** Returns the smallest integer greater than or equal to the specified float. This method will only properly ceil floats from
|
||||
* -(2^14) to (Float.MAX_VALUE - 2^14). */
|
||||
/**
|
||||
* Returns the smallest integer greater than or equal to the specified
|
||||
* float. This method will only properly ceil floats from
|
||||
* -(2^14) to (Float.MAX_VALUE - 2^14).
|
||||
*/
|
||||
static public int ceil(float x) {
|
||||
return (int) (x + BIG_ENOUGH_CEIL) - BIG_ENOUGH_INT;
|
||||
}
|
||||
|
||||
/** Returns the smallest integer greater than or equal to the specified float. This method will only properly ceil floats that
|
||||
* are positive. */
|
||||
/**
|
||||
* Returns the smallest integer greater than or equal to the specified
|
||||
* float. This method will only properly ceil floats that
|
||||
* are positive.
|
||||
*/
|
||||
static public int ceilPositive(float x) {
|
||||
return (int) (x + CEIL);
|
||||
}
|
||||
|
||||
/** Returns the closest integer to the specified float. This method will only properly round floats from -(2^14) to
|
||||
* (Float.MAX_VALUE - 2^14). */
|
||||
/**
|
||||
* Returns the closest integer to the specified float. This method will only
|
||||
* properly round floats from -(2^14) to
|
||||
* (Float.MAX_VALUE - 2^14).
|
||||
*/
|
||||
static public int round(float x) {
|
||||
return (int) (x + BIG_ENOUGH_ROUND) - BIG_ENOUGH_INT;
|
||||
}
|
||||
|
||||
/** Returns the closest integer to the specified float. This method will only properly round floats that are positive. */
|
||||
/**
|
||||
* Returns the closest integer to the specified float. This method will only
|
||||
* properly round floats that are positive.
|
||||
*/
|
||||
static public int roundPositive(float x) {
|
||||
return (int) (x + 0.5f);
|
||||
}
|
||||
|
@ -134,7 +134,8 @@ public class OBB2D {
|
||||
computeAxes();
|
||||
}
|
||||
|
||||
public void setNormalized(float cx, float cy, float vx, float vy, float width, float height, float dy) {
|
||||
public void setNormalized(float cx, float cy, float vx, float vy, float width, float height,
|
||||
float dy) {
|
||||
float ux = -vy;
|
||||
float uy = vx;
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
package org.oscim.utils;
|
||||
|
||||
/*
|
||||
|
@ -23,10 +23,13 @@ import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Allows asnynchronous execution of {@link AsyncTask} instances on a separate thread.
|
||||
* Needs to be disposed via a call to {@link #dispose()} when no longer used, in which
|
||||
* Allows asnynchronous execution of {@link AsyncTask} instances on a separate
|
||||
* thread.
|
||||
* Needs to be disposed via a call to {@link #dispose()} when no longer used, in
|
||||
* which
|
||||
* case the executor waits for running tasks to finish. Scheduled but not yet
|
||||
* running tasks will not be executed.
|
||||
*
|
||||
* @author badlogic
|
||||
*
|
||||
*/
|
||||
@ -34,8 +37,9 @@ public class AsyncExecutor {
|
||||
private final ExecutorService executor;
|
||||
|
||||
/**
|
||||
* Creates a new AsynchExecutor that allows maxConcurrent
|
||||
* {@link Runnable} instances to run in parallel.
|
||||
* Creates a new AsynchExecutor that allows maxConcurrent {@link Runnable}
|
||||
* instances to run in parallel.
|
||||
*
|
||||
* @param maxConcurrent
|
||||
*/
|
||||
public AsyncExecutor(int maxConcurrent) {
|
||||
@ -53,6 +57,7 @@ public class AsyncExecutor {
|
||||
* Submits a {@link Runnable} to be executed asynchronously. If
|
||||
* maxConcurrent runnables are already running, the runnable
|
||||
* will be queued.
|
||||
*
|
||||
* @param task the task to execute asynchronously
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@ -70,6 +75,7 @@ public class AsyncExecutor {
|
||||
* Submits a {@link Runnable} to be executed asynchronously. If
|
||||
* maxConcurrent runnables are already running, the runnable
|
||||
* will be queued.
|
||||
*
|
||||
* @param task the task to execute asynchronously
|
||||
*/
|
||||
public void post(Runnable task) {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user