Fixed iOS subsystem after transition to common renderer. Added OpenAL audio renderer. Implemented flip y in native iOS image loader

experimental
Kostyantyn Hushchyn 10 years ago
parent 7bea2cc9c7
commit eba4c4e29a
  1. 4
      jme3-ios/src/main/java/com/jme3/asset/IOS.cfg
  2. 1054
      jme3-ios/src/main/java/com/jme3/audio/android/AL.java
  3. 67
      jme3-ios/src/main/java/com/jme3/audio/android/AndroidAudioData.java
  4. 53
      jme3-ios/src/main/java/com/jme3/audio/ios/IosAL.java
  5. 26
      jme3-ios/src/main/java/com/jme3/audio/ios/IosALC.java
  6. 32
      jme3-ios/src/main/java/com/jme3/audio/ios/IosEFX.java
  7. 20
      jme3-ios/src/main/java/com/jme3/audio/plugins/AndroidAudioLoader.java
  8. 3
      jme3-ios/src/main/java/com/jme3/renderer/ios/IosGL.java
  9. 13
      jme3-ios/src/main/java/com/jme3/system/ios/IosImageLoader.java
  10. 13
      jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java
  11. 8
      jme3-ios/src/main/resources/com/jme3/asset/IOS.cfg

@ -2,3 +2,7 @@ INCLUDE com/jme3/asset/General.cfg
# IOS specific loaders # IOS specific loaders
LOADER com.jme3.system.ios.IosImageLoader : jpg, bmp, gif, png, jpeg LOADER com.jme3.system.ios.IosImageLoader : jpg, bmp, gif, png, jpeg
LOADER com.jme3.material.plugins.J3MLoader : j3m, j3md
LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, glsl, glsllib
LOADER com.jme3.export.binary.BinaryImporter : j3o
LOADER com.jme3.font.plugins.BitmapFontLoader : fnt

File diff suppressed because it is too large Load Diff

@ -1,67 +0,0 @@
package com.jme3.audio.android;
import com.jme3.asset.AssetKey;
import com.jme3.audio.AudioData;
import com.jme3.audio.AudioRenderer;
import com.jme3.util.NativeObject;
public class AndroidAudioData extends AudioData {
protected AssetKey<?> assetKey;
protected float currentVolume = 0f;
public AndroidAudioData(){
super();
}
protected AndroidAudioData(int id){
super(id);
}
public AssetKey<?> getAssetKey() {
return assetKey;
}
public void setAssetKey(AssetKey<?> assetKey) {
this.assetKey = assetKey;
}
@Override
public DataType getDataType() {
return DataType.Buffer;
}
@Override
public float getDuration() {
return 0; // TODO: ???
}
@Override
public void resetObject() {
this.id = -1;
setUpdateNeeded();
}
@Override
public void deleteObject(Object rendererObject) {
((AudioRenderer)rendererObject).deleteAudioData(this);
}
public float getCurrentVolume() {
return currentVolume;
}
public void setCurrentVolume(float currentVolume) {
this.currentVolume = currentVolume;
}
@Override
public NativeObject createDestructableClone() {
return new AndroidAudioData(id);
}
@Override
public long getUniqueId() {
return ((long)OBJTYPE_AUDIOBUFFER << 32) | ((long)id);
}
}

@ -0,0 +1,53 @@
package com.jme3.audio.ios;
import com.jme3.audio.openal.AL;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
public final class IosAL implements AL {
public IosAL() {
}
public native String alGetString(int parameter);
public native int alGenSources();
public native int alGetError();
public native void alDeleteSources(int numSources, IntBuffer sources);
public native void alGenBuffers(int numBuffers, IntBuffer buffers);
public native void alDeleteBuffers(int numBuffers, IntBuffer buffers);
public native void alSourceStop(int source);
public native void alSourcei(int source, int param, int value);
public native void alBufferData(int buffer, int format, ByteBuffer data, int size, int frequency);
public native void alSourcePlay(int source);
public native void alSourcePause(int source);
public native void alSourcef(int source, int param, float value);
public native void alSource3f(int source, int param, float value1, float value2, float value3);
public native int alGetSourcei(int source, int param);
public native void alSourceUnqueueBuffers(int source, int numBuffers, IntBuffer buffers);
public native void alSourceQueueBuffers(int source, int numBuffers, IntBuffer buffers);
public native void alListener(int param, FloatBuffer data);
public native void alListenerf(int param, float value);
public native void alListener3f(int param, float value1, float value2, float value3);
public native void alSource3i(int source, int param, int value1, int value2, int value3);
}

@ -0,0 +1,26 @@
package com.jme3.audio.ios;
import com.jme3.audio.openal.ALC;
import java.nio.IntBuffer;
public final class IosALC implements ALC {
public IosALC() {
}
public native void createALC();
public native void destroyALC();
public native boolean isCreated();
public native String alcGetString(int parameter);
public native boolean alcIsExtensionPresent(String extension);
public native void alcGetInteger(int param, IntBuffer buffer, int size);
public native void alcDevicePauseSOFT();
public native void alcDeviceResumeSOFT();
}

@ -0,0 +1,32 @@
package com.jme3.audio.ios;
import com.jme3.audio.openal.EFX;
import java.nio.IntBuffer;
public class IosEFX implements EFX {
public IosEFX() {
}
public native void alGenAuxiliaryEffectSlots(int numSlots, IntBuffer buffers);
public native void alGenEffects(int numEffects, IntBuffer buffers);
public native void alEffecti(int effect, int param, int value);
public native void alAuxiliaryEffectSloti(int effectSlot, int param, int value);
public native void alDeleteEffects(int numEffects, IntBuffer buffers);
public native void alDeleteAuxiliaryEffectSlots(int numEffectSlots, IntBuffer buffers);
public native void alGenFilters(int numFilters, IntBuffer buffers);
public native void alFilteri(int filter, int param, int value);
public native void alFilterf(int filter, int param, float value);
public native void alDeleteFilters(int numFilters, IntBuffer buffers);
public native void alEffectf(int effect, int param, float value);
}

@ -1,20 +0,0 @@
package com.jme3.audio.plugins;
import com.jme3.asset.AssetInfo;
import com.jme3.asset.AssetLoader;
import com.jme3.audio.android.AndroidAudioData;
import java.io.IOException;
/**
* <code>AndroidAudioLoader</code> will create an
* {@link AndroidAudioData} object with the specified asset key.
*/
public class AndroidAudioLoader implements AssetLoader {
@Override
public Object load(AssetInfo assetInfo) throws IOException {
AndroidAudioData result = new AndroidAudioData();
result.setAssetKey(assetInfo.getKey());
return result;
}
}

@ -34,6 +34,7 @@ package com.jme3.renderer.ios;
import com.jme3.renderer.RendererException; import com.jme3.renderer.RendererException;
import com.jme3.renderer.opengl.GL; import com.jme3.renderer.opengl.GL;
import com.jme3.renderer.opengl.GLExt; import com.jme3.renderer.opengl.GLExt;
import com.jme3.renderer.opengl.GLFbo;
import java.nio.Buffer; import java.nio.Buffer;
import java.nio.BufferOverflowException; import java.nio.BufferOverflowException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -46,7 +47,7 @@ import java.nio.ShortBuffer;
* *
* @author Kirill Vainer * @author Kirill Vainer
*/ */
public class IosGL implements GL, GLExt { public class IosGL implements GL, GLExt, GLFbo {
private final int[] temp_array = new int[16]; private final int[] temp_array = new int[16];

@ -33,6 +33,7 @@ package com.jme3.system.ios;
import com.jme3.asset.AssetInfo; import com.jme3.asset.AssetInfo;
import com.jme3.asset.AssetLoader; import com.jme3.asset.AssetLoader;
import com.jme3.asset.TextureKey;
import com.jme3.texture.Image; import com.jme3.texture.Image;
import com.jme3.texture.Image.Format; import com.jme3.texture.Image.Format;
import java.io.IOException; import java.io.IOException;
@ -45,15 +46,17 @@ import java.io.InputStream;
public class IosImageLoader implements AssetLoader { public class IosImageLoader implements AssetLoader {
public Object load(AssetInfo info) throws IOException { public Object load(AssetInfo info) throws IOException {
InputStream in = info.openStream(); boolean flip = ((TextureKey) info.getKey()).isFlipY();
Image img = null; Image img = null;
InputStream in = null;
try { try {
img = loadImageData(Image.Format.RGBA8, in); in = info.openStream();
} catch (Exception e) { img = loadImageData(Format.RGBA8, flip, in);
e.printStackTrace();
} finally { } finally {
if (in != null) {
in.close(); in.close();
} }
}
return img; return img;
} }
@ -64,5 +67,5 @@ public class IosImageLoader implements AssetLoader {
* @param inputStream the InputStream to load the image data from * @param inputStream the InputStream to load the image data from
* @return the loaded Image * @return the loaded Image
*/ */
private static native Image loadImageData(Format format, InputStream inputStream); private static native Image loadImageData(Format format, boolean flipY, InputStream inputStream);
} }

@ -36,6 +36,14 @@ import com.jme3.system.AppSettings;
import com.jme3.system.JmeContext; import com.jme3.system.JmeContext;
import com.jme3.system.JmeSystemDelegate; import com.jme3.system.JmeSystemDelegate;
import com.jme3.system.NullContext; import com.jme3.system.NullContext;
import com.jme3.audio.AudioRenderer;
import com.jme3.audio.ios.IosAL;
import com.jme3.audio.ios.IosALC;
//import com.jme3.audio.ios.IosEFX;
import com.jme3.audio.openal.AL;
import com.jme3.audio.openal.ALAudioRenderer;
import com.jme3.audio.openal.ALC;
import com.jme3.audio.openal.EFX;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL; import java.net.URL;
@ -89,7 +97,10 @@ public class JmeIosSystem extends JmeSystemDelegate {
@Override @Override
public AudioRenderer newAudioRenderer(AppSettings settings) { public AudioRenderer newAudioRenderer(AppSettings settings) {
return null; ALC alc = new IosALC();
AL al = new IosAL();
//EFX efx = new IosEFX();
return new ALAudioRenderer(al, alc, null);
} }
@Override @Override

@ -0,0 +1,8 @@
INCLUDE com/jme3/asset/General.cfg
# IOS specific loaders
LOADER com.jme3.system.ios.IosImageLoader : jpg, bmp, gif, png, jpeg
LOADER com.jme3.material.plugins.J3MLoader : j3m, j3md
LOADER com.jme3.shader.plugins.GLSLLoader : vert, frag, glsl, glsllib
LOADER com.jme3.export.binary.BinaryImporter : j3o
LOADER com.jme3.font.plugins.BitmapFontLoader : fnt
Loading…
Cancel
Save