Android: Added pressure to touch event and allow standard jme images as cube maps
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7578 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
443e49925d
commit
f42b7e8f83
@ -20,6 +20,11 @@ import com.jme3.math.Vector2f;
|
|||||||
import com.jme3.util.RingBuffer;
|
import com.jme3.util.RingBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <code>AndroidInput</code> is one of the main components that connect jme with android. Is derived from GLSurfaceView and handles all Inputs
|
||||||
|
* @author larynx
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class AndroidInput extends GLSurfaceView implements TouchInput,
|
public class AndroidInput extends GLSurfaceView implements TouchInput,
|
||||||
GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener
|
GestureDetector.OnGestureListener, ScaleGestureDetector.OnScaleGestureListener
|
||||||
{
|
{
|
||||||
@ -218,6 +223,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput,
|
|||||||
touch.set(Type.DOWN, event.getX(p), event.getY(p), 0, 0);
|
touch.set(Type.DOWN, event.getX(p), event.getY(p), 0, 0);
|
||||||
touch.setPointerId(event.getPointerId(p));
|
touch.setPointerId(event.getPointerId(p));
|
||||||
touch.setTime(event.getEventTime());
|
touch.setTime(event.getEventTime());
|
||||||
|
touch.setPressure(event.getPressure(p));
|
||||||
processEvent(touch);
|
processEvent(touch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,6 +239,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput,
|
|||||||
touch.set(Type.UP, event.getX(p), event.getY(p), 0, 0);
|
touch.set(Type.UP, event.getX(p), event.getY(p), 0, 0);
|
||||||
touch.setPointerId(event.getPointerId(p));
|
touch.setPointerId(event.getPointerId(p));
|
||||||
touch.setTime(event.getEventTime());
|
touch.setTime(event.getEventTime());
|
||||||
|
touch.setPressure(event.getPressure(p));
|
||||||
processEvent(touch);
|
processEvent(touch);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +260,7 @@ public class AndroidInput extends GLSurfaceView implements TouchInput,
|
|||||||
touch.set(Type.MOVE, event.getX(p), event.getY(p), event.getX(p) - lastPos.x, event.getY(p) - lastPos.y);
|
touch.set(Type.MOVE, event.getX(p), event.getY(p), event.getX(p) - lastPos.x, event.getY(p) - lastPos.y);
|
||||||
touch.setPointerId(event.getPointerId(p));
|
touch.setPointerId(event.getPointerId(p));
|
||||||
touch.setTime(event.getEventTime());
|
touch.setTime(event.getEventTime());
|
||||||
|
touch.setPressure(event.getPressure(p));
|
||||||
processEvent(touch);
|
processEvent(touch);
|
||||||
lastPos.set(event.getX(p), event.getY(p));
|
lastPos.set(event.getX(p), event.getY(p));
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
package com.jme3.renderer.android;
|
package com.jme3.renderer.android;
|
||||||
|
|
||||||
import com.jme3.asset.TextureKey;
|
|
||||||
import com.jme3.light.LightList;
|
import com.jme3.light.LightList;
|
||||||
import com.jme3.material.RenderState;
|
import com.jme3.material.RenderState;
|
||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
@ -58,7 +57,6 @@ import com.jme3.shader.Shader;
|
|||||||
import com.jme3.shader.Shader.ShaderSource;
|
import com.jme3.shader.Shader.ShaderSource;
|
||||||
import com.jme3.shader.Shader.ShaderType;
|
import com.jme3.shader.Shader.ShaderType;
|
||||||
import com.jme3.shader.Uniform;
|
import com.jme3.shader.Uniform;
|
||||||
import com.jme3.system.JmeSystem;
|
|
||||||
import com.jme3.texture.FrameBuffer;
|
import com.jme3.texture.FrameBuffer;
|
||||||
import com.jme3.texture.FrameBuffer.RenderBuffer;
|
import com.jme3.texture.FrameBuffer.RenderBuffer;
|
||||||
import com.jme3.texture.Image;
|
import com.jme3.texture.Image;
|
||||||
@ -385,12 +383,19 @@ public class OGLESShaderRenderer implements Renderer {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
String extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);
|
String extensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);
|
||||||
|
logger.info("GL_EXTENSIONS: " + extensions);
|
||||||
|
|
||||||
logger.info("GL_EXTENSIONS: " + extensions);
|
GLES20.glGetIntegerv(GLES20.GL_COMPRESSED_TEXTURE_FORMATS, intBuf16);
|
||||||
|
for (int i = 0; i < intBuf16.limit(); i++)
|
||||||
|
{
|
||||||
|
logger.info("Compressed Texture Formats: " + intBuf16.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
if (extensions.contains("GL_OES_texture_npot"))
|
if (extensions.contains("GL_OES_texture_npot"))
|
||||||
powerOf2 = true;
|
powerOf2 = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
applyRenderState(RenderState.DEFAULT);
|
applyRenderState(RenderState.DEFAULT);
|
||||||
// GLES20.glClearDepthf(1.0f);
|
// GLES20.glClearDepthf(1.0f);
|
||||||
|
|
||||||
@ -1834,14 +1839,31 @@ public class OGLESShaderRenderer implements Renderer {
|
|||||||
// Upload a cube map / sky box
|
// Upload a cube map / sky box
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Bitmap> bmps = (List<Bitmap>)img.getEfficentData();
|
List<Bitmap> bmps = (List<Bitmap>)img.getEfficentData();
|
||||||
if (bmps.size() != 6)
|
if (bmps != null)
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("Invalid texture: " + img +
|
// Native android bitmap
|
||||||
"Cubemap textures must contain 6 data units." );
|
if (bmps.size() != 6)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException("Invalid texture: " + img +
|
||||||
|
"Cubemap textures must contain 6 data units." );
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
TextureUtil.uploadTextureBitmap(GLES20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, bmps.get(i), false, powerOf2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 6; i++)
|
else
|
||||||
{
|
{
|
||||||
TextureUtil.uploadTextureBitmap(GLES20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, bmps.get(i), false, powerOf2);
|
// Standard jme3 image data
|
||||||
|
List<ByteBuffer> data = img.getData();
|
||||||
|
if (data.size() != 6) {
|
||||||
|
logger.log(Level.WARNING, "Invalid texture: {0}\n"
|
||||||
|
+ "Cubemap textures must contain 6 data units.", img);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
TextureUtil.uploadTexture(img, GLES20.GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, i, 0, tdc, false, powerOf2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
package com.jme3.renderer.android;
|
package com.jme3.renderer.android;
|
||||||
|
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.opengl.GLES10;
|
||||||
|
import android.opengl.GLES11;
|
||||||
|
import android.opengl.GLES11Ext;
|
||||||
import android.opengl.GLES20;
|
import android.opengl.GLES20;
|
||||||
import android.opengl.GLUtils;
|
import android.opengl.GLUtils;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
@ -8,6 +12,7 @@ import com.jme3.texture.Image;
|
|||||||
import com.jme3.texture.Image.Format;
|
import com.jme3.texture.Image.Format;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import javax.microedition.khronos.opengles.GL10;
|
import javax.microedition.khronos.opengles.GL10;
|
||||||
|
import javax.microedition.khronos.opengles.GL10Ext;
|
||||||
|
|
||||||
public class TextureUtil {
|
public class TextureUtil {
|
||||||
|
|
||||||
@ -32,8 +37,10 @@ public class TextureUtil {
|
|||||||
case RGBA16:
|
case RGBA16:
|
||||||
case RGBA8:
|
case RGBA8:
|
||||||
return GL10.GL_RGBA;
|
return GL10.GL_RGBA;
|
||||||
|
case DXT1A:
|
||||||
|
throw new UnsupportedOperationException("Unsupported format: " + fmt);
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Unrecognized format: "+fmt);
|
throw new UnsupportedOperationException("Unrecognized format: " + fmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +196,9 @@ public class TextureUtil {
|
|||||||
format = GL10.GL_RGBA;
|
format = GL10.GL_RGBA;
|
||||||
dataType = GL10.GL_UNSIGNED_BYTE;
|
dataType = GL10.GL_UNSIGNED_BYTE;
|
||||||
break;
|
break;
|
||||||
|
case DXT1A:
|
||||||
|
format = GLES20.GL_COMPRESSED_TEXTURE_FORMATS;
|
||||||
|
dataType = GL10.GL_UNSIGNED_BYTE;
|
||||||
default:
|
default:
|
||||||
throw new UnsupportedOperationException("Unrecognized format: "+fmt);
|
throw new UnsupportedOperationException("Unrecognized format: "+fmt);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user