rename vtm-gdx-dektop to vtm-desktop
This commit is contained in:
138
vtm-desktop/src/org/oscim/awt/AwtBitmap.java
Normal file
138
vtm-desktop/src/org/oscim/awt/AwtBitmap.java
Normal file
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.awt;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.utils.BufferUtils;
|
||||
|
||||
public class AwtBitmap implements Bitmap {
|
||||
BufferedImage bitmap;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
boolean internal;
|
||||
|
||||
public AwtBitmap(int width, int height, int format) {
|
||||
bitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
internal = true;
|
||||
// if (!this.bitmap.isAlphaPremultiplied())
|
||||
// this.bitmap.coerceData(true);
|
||||
}
|
||||
|
||||
AwtBitmap(InputStream inputStream) throws IOException {
|
||||
|
||||
this.bitmap = ImageIO.read(inputStream);
|
||||
this.width = this.bitmap.getWidth();
|
||||
this.height = this.bitmap.getHeight();
|
||||
if (!this.bitmap.isAlphaPremultiplied()
|
||||
&& this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB)
|
||||
this.bitmap.coerceData(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getPixels() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseColor(int transparent) {
|
||||
}
|
||||
|
||||
private final static IntBuffer tmpBuffer = BufferUtils.newIntBuffer(512 * 256);
|
||||
private final static int[] tmpPixel = new int[512 * 256];
|
||||
|
||||
private final static boolean WRITE_TEX = false;
|
||||
private int dbgCnt;
|
||||
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
int[] pixels;
|
||||
IntBuffer buffer;
|
||||
|
||||
if (width * height < 512 * 256) {
|
||||
pixels = tmpPixel;
|
||||
buffer = tmpBuffer;
|
||||
buffer.clear();
|
||||
} else {
|
||||
pixels = new int[width * height];
|
||||
buffer = BufferUtils.newIntBuffer(width * height);
|
||||
}
|
||||
|
||||
// FIXME dont convert to argb when there data is greyscale
|
||||
bitmap.getRGB(0, 0, width, height, pixels, 0, width);
|
||||
|
||||
if (WRITE_TEX) {
|
||||
try {
|
||||
boolean ok = ImageIO.write(bitmap, "png", new File("texture_" + dbgCnt + ".png"));
|
||||
System.out.println("write tex " + ok + " " + dbgCnt);
|
||||
dbgCnt++;
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0, n = width * height; i < n; i++) {
|
||||
int c = pixels[i];
|
||||
|
||||
float alpha = (c >>> 24) / 255f;
|
||||
int r = (int) ((c & 0x000000ff) * alpha);
|
||||
int b = (int) (((c & 0x00ff0000) >>> 16) * alpha);
|
||||
int g = (int) (((c & 0x0000ff00) >>> 8) * alpha);
|
||||
pixels[i] = (c & 0xff000000) | r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
buffer.put(pixels, 0, width * height);
|
||||
buffer.flip();
|
||||
|
||||
Gdx.gl20.glTexImage2D(GL20.GL_TEXTURE_2D, 0, GL20.GL_RGBA, width,
|
||||
height, 0, GL20.GL_RGBA, GL20.GL_UNSIGNED_BYTE, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
108
vtm-desktop/src/org/oscim/awt/AwtCanvas.java
Normal file
108
vtm-desktop/src/org/oscim/awt/AwtCanvas.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.awt;
|
||||
|
||||
import java.awt.AlphaComposite;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.font.TextLayout;
|
||||
import java.awt.geom.AffineTransform;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class AwtCanvas implements Canvas {
|
||||
|
||||
Graphics2D canvas;
|
||||
|
||||
public AwtCanvas() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
if (canvas != null)
|
||||
canvas.dispose();
|
||||
|
||||
AwtBitmap awtBitamp = (AwtBitmap) bitmap;
|
||||
|
||||
canvas = awtBitamp.bitmap.createGraphics();
|
||||
|
||||
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0));
|
||||
canvas.fillRect(0, 0, bitmap.getWidth(), bitmap.getHeight());
|
||||
|
||||
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
|
||||
|
||||
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) {
|
||||
|
||||
// if (paint.isTransparent()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
AwtPaint awtPaint = (AwtPaint) paint;
|
||||
|
||||
//AwtPaint awtPaint = AwtGraphicFactory.getAwtPaint(paint);
|
||||
|
||||
if (awtPaint.stroke == null) {
|
||||
canvas.setColor(awtPaint.color);
|
||||
canvas.setFont(awtPaint.font);
|
||||
canvas.drawString(text, x + 2, y);
|
||||
} else {
|
||||
setColorAndStroke(awtPaint);
|
||||
TextLayout textLayout = new TextLayout(text,
|
||||
awtPaint.font,
|
||||
canvas.getFontRenderContext());
|
||||
AffineTransform affineTransform = new AffineTransform();
|
||||
affineTransform.translate(x + 2, y);
|
||||
canvas.draw(textLayout.getOutline(affineTransform));
|
||||
}
|
||||
}
|
||||
|
||||
private void setColorAndStroke(AwtPaint awtPaint) {
|
||||
canvas.setColor(awtPaint.color);
|
||||
if (awtPaint.stroke != null) {
|
||||
canvas.setStroke(awtPaint.stroke);
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void drawText(String string, float x, float y, Paint stroke) {
|
||||
// AwtPaint p = (AwtPaint)stroke;
|
||||
//
|
||||
// canvas.setFont(p.font);
|
||||
// canvas.setColor(p.color);
|
||||
//
|
||||
// canvas.drawString(string, (int)x, (int)y);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnknownError("not implemented");
|
||||
}
|
||||
}
|
||||
108
vtm-desktop/src/org/oscim/awt/AwtGraphics.java
Normal file
108
vtm-desktop/src/org/oscim/awt/AwtGraphics.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.awt;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class AwtGraphics extends CanvasAdapter {
|
||||
private static final AwtGraphics INSTANCE = new AwtGraphics();
|
||||
|
||||
public static final AwtGraphics get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private AwtGraphics() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint getPaint() {
|
||||
return new AwtPaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBitmap(int width, int height, int format) {
|
||||
return new AwtBitmap(width, height, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Canvas getCanvas() {
|
||||
return new AwtCanvas();
|
||||
}
|
||||
|
||||
static final BufferedImage image;
|
||||
|
||||
static final Graphics2D canvas;
|
||||
|
||||
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_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
|
||||
FontMetrics fm = canvas.getFontMetrics();
|
||||
// int ascent = fm.getMaxAscent();
|
||||
// int descent = fm.getMaxDescent();
|
||||
// int advance = fm.charWidth('W'); // width of widest char, more
|
||||
// reliable than getMaxAdvance();
|
||||
// int leading = fm.getLeading();
|
||||
//
|
||||
return fm;
|
||||
}
|
||||
|
||||
static synchronized float getTextWidth(FontMetrics fm, String text) {
|
||||
//return (float)fm.getStringBounds(text, canvas).getWidth();
|
||||
return fm.stringWidth(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap decodeBitmap(InputStream inputStream) {
|
||||
try {
|
||||
return new AwtBitmap(inputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadBitmapAsset(String fileName) {
|
||||
try {
|
||||
return createBitmap(fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
181
vtm-desktop/src/org/oscim/awt/AwtPaint.java
Normal file
181
vtm-desktop/src/org/oscim/awt/AwtPaint.java
Normal file
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.awt;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Stroke;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.text.AttributedCharacterIterator.Attribute;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class AwtPaint implements Paint {
|
||||
|
||||
private static int getCap(Cap cap) {
|
||||
switch (cap) {
|
||||
case BUTT:
|
||||
return BasicStroke.CAP_BUTT;
|
||||
case ROUND:
|
||||
return BasicStroke.CAP_ROUND;
|
||||
case SQUARE:
|
||||
return BasicStroke.CAP_SQUARE;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown cap: " + cap);
|
||||
}
|
||||
|
||||
static final Font defaultFont;
|
||||
static {
|
||||
Map<Attribute, Object> textAttributes = new HashMap<Attribute, Object>();
|
||||
textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
|
||||
textAttributes.put(TextAttribute.FAMILY, "Arial");
|
||||
textAttributes.put(TextAttribute.SIZE, 14);
|
||||
|
||||
defaultFont = Font.getFont(textAttributes);
|
||||
}
|
||||
|
||||
Font font = defaultFont; // new Font("Default", Font.PLAIN, 13);
|
||||
Stroke stroke;
|
||||
FontMetrics fm;
|
||||
Color color = new Color(0.1f, 0.1f, 0.1f, 1);
|
||||
|
||||
private int cap;
|
||||
private float strokeWidth;
|
||||
|
||||
//private Align mAlign;
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextHeight(String text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextWidth(String text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmapShader(Bitmap bitmap) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int c) {
|
||||
color = new Color(((c >> 16) & 0xff) / 255f,
|
||||
((c >> 8) & 0xff) / 255f,
|
||||
((c >> 0) & 0xff) / 255f,
|
||||
((c >> 24) & 0xff) / 255f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDashPathEffect(float[] strokeDasharray) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeCap(Cap cap) {
|
||||
this.cap = getCap(cap);
|
||||
createStroke();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeWidth(float width) {
|
||||
strokeWidth = width;
|
||||
createStroke();
|
||||
|
||||
// int size = font.getSize();
|
||||
// font = font.deriveFont(size + width * 4);
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(Style style) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextAlign(Align align) {
|
||||
//mAlign = align;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float textSize) {
|
||||
font = font.deriveFont(textSize - 2);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float measureText(String text) {
|
||||
if (fm == null)
|
||||
fm = AwtGraphics.getFontMetrics(this.font);
|
||||
|
||||
float w = AwtGraphics.getTextWidth(fm, text);
|
||||
//Gdx.app.log("text width:", text + " " + w);
|
||||
return w + 4;
|
||||
// return fm.getStringBounds(text, A).getWidth();
|
||||
// return AwtGraphics.getTextWidth(fm, text);
|
||||
// return fm.stringWidth(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontHeight() {
|
||||
if (fm == null)
|
||||
fm = AwtGraphics.getFontMetrics(this.font);
|
||||
|
||||
float height = fm.getHeight();
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontDescent() {
|
||||
if (fm == null)
|
||||
fm = AwtGraphics.getFontMetrics(this.font);
|
||||
|
||||
float desc = fm.getDescent();
|
||||
|
||||
return desc;
|
||||
}
|
||||
|
||||
private void createStroke() {
|
||||
if (strokeWidth <= 0) {
|
||||
return;
|
||||
}
|
||||
stroke = new BasicStroke(strokeWidth, cap, BasicStroke.JOIN_MITER, 1, null, 0);
|
||||
}
|
||||
}
|
||||
895
vtm-desktop/src/org/oscim/gdx/GdxGL20.java
Normal file
895
vtm-desktop/src/org/oscim/gdx/GdxGL20.java
Normal file
@@ -0,0 +1,895 @@
|
||||
package org.oscim.gdx;
|
||||
|
||||
/*******************************************************************************
|
||||
* Copyright 2011 Mario Zechner <badlogicgames@gmail.com>
|
||||
* Copyright 2011 Nathan Sweet <nathan.sweet@gmail.com>
|
||||
*
|
||||
* 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.
|
||||
******************************************************************************/
|
||||
|
||||
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.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
|
||||
*/
|
||||
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 == GL_UNSIGNED_SHORT)
|
||||
GL11.glDrawElements(mode, (ShortBuffer) indices);
|
||||
else if (indices instanceof ByteBuffer && type == GL_UNSIGNED_SHORT)
|
||||
GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); // FIXME yay...
|
||||
else if (indices instanceof ByteBuffer && type == 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);
|
||||
size.put(typeTmp.get(0));
|
||||
if (type instanceof IntBuffer)
|
||||
((IntBuffer) type).put(typeTmp.get(1));
|
||||
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);
|
||||
size.put(typeTmp.get(0));
|
||||
if (type instanceof IntBuffer)
|
||||
((IntBuffer) type).put(typeTmp.get(1));
|
||||
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 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
97
vtm-desktop/src/org/oscim/gdx/GdxMapApp.java
Normal file
97
vtm-desktop/src/org/oscim/gdx/GdxMapApp.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.gdx;
|
||||
|
||||
import org.oscim.awt.AwtGraphics;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.GLAdapter;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
import org.oscim.utils.FastMath;
|
||||
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||
import com.badlogic.gdx.utils.SharedLibraryLoader;
|
||||
|
||||
public class GdxMapApp extends GdxMap {
|
||||
static {
|
||||
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
|
||||
}
|
||||
|
||||
// wrap LwjglGL20 to add GL20 interface
|
||||
// static class GdxGL extends GdxGL20 {
|
||||
// @Override
|
||||
// public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
// throw new IllegalArgumentException("not implemented");
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void init() {
|
||||
// load native library
|
||||
new SharedLibraryLoader().load("vtm-jni");
|
||||
// init globals
|
||||
CanvasAdapter.g = AwtGraphics.get();
|
||||
GLAdapter.g = new GdxGL20();
|
||||
|
||||
GLAdapter.GDX_DESKTOP_QUIRKS = true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Tile.SIZE = 360;
|
||||
init();
|
||||
new LwjglApplication(new GdxMapApp(), getConfig());
|
||||
}
|
||||
|
||||
public static void run(GdxMap map, LwjglApplicationConfiguration config, int tileSize) {
|
||||
Tile.SIZE = FastMath.clamp(tileSize, 128, 512);
|
||||
|
||||
new LwjglApplication(map, (config == null ? getConfig() : config));
|
||||
}
|
||||
|
||||
public static void run(LwjglApplicationConfiguration config, int tileSize, GdxMap map) {
|
||||
run(map, config, tileSize);
|
||||
}
|
||||
|
||||
static protected LwjglApplicationConfiguration getConfig() {
|
||||
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
|
||||
cfg.title = "vtm-gdx";
|
||||
//cfg.useGL20 = true;
|
||||
cfg.width = 1280;
|
||||
cfg.height = 800;
|
||||
cfg.stencil = 8;
|
||||
cfg.samples = 2;
|
||||
cfg.foregroundFPS = 30;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createLayers() {
|
||||
TileSource tileSource = new OSciMap4TileSource();
|
||||
|
||||
// TileSource tileSource = new MapFileTileSource();
|
||||
// tileSource.setOption("file", "/home/jeff/germany.map");
|
||||
|
||||
initDefaultLayers(tileSource, false, true, true);
|
||||
|
||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ImagicoLandcover(), 20));
|
||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new OSMTileSource(), 20));
|
||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ArcGISWorldShaded(), 20));
|
||||
|
||||
mMap.setMapPosition(0, 0, 1 << 2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user