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
3.0
kim..ng 14 years ago
parent 443e49925d
commit f42b7e8f83
  1. 8
      engine/src/android/com/jme3/input/android/AndroidInput.java
  2. 28
      engine/src/android/com/jme3/renderer/android/OGLESShaderRenderer.java
  3. 10
      engine/src/android/com/jme3/renderer/android/TextureUtil.java

@ -20,6 +20,11 @@ import com.jme3.math.Vector2f;
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,
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.setPointerId(event.getPointerId(p));
touch.setTime(event.getEventTime());
touch.setPressure(event.getPressure(p));
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.setPointerId(event.getPointerId(p));
touch.setTime(event.getEventTime());
touch.setPressure(event.getPressure(p));
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.setPointerId(event.getPointerId(p));
touch.setTime(event.getEventTime());
touch.setPressure(event.getPressure(p));
processEvent(touch);
lastPos.set(event.getX(p), event.getY(p));
}

@ -32,7 +32,6 @@
package com.jme3.renderer.android;
import com.jme3.asset.TextureKey;
import com.jme3.light.LightList;
import com.jme3.material.RenderState;
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.ShaderType;
import com.jme3.shader.Uniform;
import com.jme3.system.JmeSystem;
import com.jme3.texture.FrameBuffer;
import com.jme3.texture.FrameBuffer.RenderBuffer;
import com.jme3.texture.Image;
@ -385,12 +383,19 @@ public class OGLESShaderRenderer implements Renderer {
*/
String extensions = GLES20.glGetString(GLES20.GL_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"))
powerOf2 = true;
applyRenderState(RenderState.DEFAULT);
// GLES20.glClearDepthf(1.0f);
@ -1834,6 +1839,9 @@ public class OGLESShaderRenderer implements Renderer {
// Upload a cube map / sky box
@SuppressWarnings("unchecked")
List<Bitmap> bmps = (List<Bitmap>)img.getEfficentData();
if (bmps != null)
{
// Native android bitmap
if (bmps.size() != 6)
{
throw new UnsupportedOperationException("Invalid texture: " + img +
@ -1845,6 +1853,20 @@ public class OGLESShaderRenderer implements Renderer {
}
}
else
{
// 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
{
TextureUtil.uploadTexture(img, target, 0, 0, tdc, false, powerOf2);

@ -1,6 +1,10 @@
package com.jme3.renderer.android;
import android.graphics.Bitmap;
import android.opengl.GLES10;
import android.opengl.GLES11;
import android.opengl.GLES11Ext;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import com.jme3.math.FastMath;
@ -8,6 +12,7 @@ import com.jme3.texture.Image;
import com.jme3.texture.Image.Format;
import java.nio.ByteBuffer;
import javax.microedition.khronos.opengles.GL10;
import javax.microedition.khronos.opengles.GL10Ext;
public class TextureUtil {
@ -32,6 +37,8 @@ public class TextureUtil {
case RGBA16:
case RGBA8:
return GL10.GL_RGBA;
case DXT1A:
throw new UnsupportedOperationException("Unsupported format: " + fmt);
default:
throw new UnsupportedOperationException("Unrecognized format: " + fmt);
}
@ -189,6 +196,9 @@ public class TextureUtil {
format = GL10.GL_RGBA;
dataType = GL10.GL_UNSIGNED_BYTE;
break;
case DXT1A:
format = GLES20.GL_COMPRESSED_TEXTURE_FORMATS;
dataType = GL10.GL_UNSIGNED_BYTE;
default:
throw new UnsupportedOperationException("Unrecognized format: "+fmt);
}

Loading…
Cancel
Save