Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/backends/gdx-backend-robovm/build-objectal.sh b/backends/gdx-backend-robovm/build-objectal.sh
- index d6fa45e..6e672d7 100755
- --- a/backends/gdx-backend-robovm/build-objectal.sh
- +++ b/backends/gdx-backend-robovm/build-objectal.sh
- @@ -1,17 +1,36 @@
- #!/bin/bash
- -curl https://codeload.github.com/kstenerud/ObjectAL-for-iPhone/legacy.tar.gz/master -o objectal.tar.gz
- -tar xvfz objectal.tar.gz
- -cd kstenerud-ObjectAL-for-iPhone-a2252f3/ObjectAL
- -xcodebuild -arch armv7 -sdk iphoneos
- -cp build/Release-iphoneos/libObjectAl.a build/libObjectAl.a.armv7
- -xcodebuild -arch arm64 -sdk iphoneos
- -cp build/Release-iphoneos/libObjectAl.a build/libObjectAl.a.arm64
- -xcodebuild -arch i386 -sdk iphonesimulator
- -cp build/Release-iphonesimulator/libObjectAl.a build/libObjectAl.a.i386
- -xcodebuild -arch x86_64 -sdk iphonesimulator
- -cp build/Release-iphonesimulator/libObjectAl.a build/libObjectAl.a.x86_64
- -lipo build/libObjectAL.a.armv7 build/libObjectAL.a.arm64 build/libObjectAL.a.i386 build/libObjectAL.a.x86_64 -create -output build/libObjectAL.a
- -cp build/libObjectAL.a ../../../../gdx/libs/ios32/
- -cd ../..
- -rm objectal.tar.gz
- -rm -r kstenerud-ObjectAL-for-iPhone-a2252f3/
- +
- +BASE=$(cd $(dirname $0); pwd -P)
- +
- +BUILD_DIR=$BASE/target/objectal
- +rm -rf $BUILD_DIR
- +mkdir -p $BUILD_DIR
- +
- +curl https://codeload.github.com/libgdx/ObjectAL-for-iPhone/legacy.tar.gz/master -o $BUILD_DIR/objectal.tar.gz
- +
- +tar xvfz $BUILD_DIR/objectal.tar.gz -C $BUILD_DIR --strip-components 1
- +
- +XCODEPROJ=$BUILD_DIR/ObjectAL/ObjectAL.xcodeproj
- +
- +xcodebuild -project $XCODEPROJ -arch armv7 -sdk iphoneos CONFIGURATION_BUILD_DIR=$BUILD_DIR/armv7 OTHER_CFLAGS="-fembed-bitcode -miphoneos-version-min=6.0"
- +xcodebuild -project $XCODEPROJ -arch arm64 -sdk iphoneos CONFIGURATION_BUILD_DIR=$BUILD_DIR/arm64 OTHER_CFLAGS="-fembed-bitcode -miphoneos-version-min=6.0"
- +xcodebuild -project $XCODEPROJ -arch i386 -sdk iphonesimulator CONFIGURATION_BUILD_DIR=$BUILD_DIR/i386 OTHER_CFLAGS="-miphoneos-version-min=6.0"
- +xcodebuild -project $XCODEPROJ -arch x86_64 -sdk iphonesimulator CONFIGURATION_BUILD_DIR=$BUILD_DIR/x86_64 OTHER_CFLAGS="-miphoneos-version-min=6.0"
- +xcodebuild -project $XCODEPROJ -arch arm64 -sdk appletvos CONFIGURATION_BUILD_DIR=$BUILD_DIR/tvos-arm64 OTHER_CFLAGS="-fembed-bitcode -mtvos-version-min=9.0"
- +xcodebuild -project $XCODEPROJ -arch x86_64 -sdk appletvsimulator CONFIGURATION_BUILD_DIR=$BUILD_DIR/tvos-x86_64 OTHER_CFLAGS="-mtvos-version-min=9.0"
- +
- +lipo $BUILD_DIR/armv7/libObjectAL.a \
- + $BUILD_DIR/arm64/libObjectAL.a \
- + $BUILD_DIR/i386/libObjectAL.a \
- + $BUILD_DIR/x86_64/libObjectAL.a \
- + -create \
- + -output $BUILD_DIR/libObjectAL.a
- +
- +cp $BUILD_DIR/libObjectAL.a $BASE/../../gdx/libs/ios32/
- +
- +lipo $BUILD_DIR/tvos-arm64/libObjectAL.a \
- + $BUILD_DIR/tvos-x86_64/libObjectAL.a \
- + -create \
- + -output $BUILD_DIR/libObjectAL.a.tvos
- +
- +cp $BUILD_DIR/libObjectAL.a.tvos $BASE/../../gdx/libs/ios32/
- diff --git a/backends/gdx-backend-robovm/pom.xml b/backends/gdx-backend-robovm/pom.xml
- index 3357905..8bc0d95 100644
- --- a/backends/gdx-backend-robovm/pom.xml
- +++ b/backends/gdx-backend-robovm/pom.xml
- @@ -4,7 +4,7 @@
- <parent>
- <groupId>com.badlogicgames.gdx</groupId>
- <artifactId>gdx-parent</artifactId>
- - <version>1.7.0</version>
- + <version>1.9.3-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
- diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplication.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplication.java
- index a61770c..4640691 100644
- --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplication.java
- +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplication.java
- @@ -18,7 +18,7 @@ package com.badlogic.gdx.backends.iosrobovm;
- import java.io.File;
- -import org.robovm.apple.coregraphics.CGSize;
- +import org.robovm.apple.coregraphics.CGRect;
- import org.robovm.apple.foundation.Foundation;
- import org.robovm.apple.foundation.NSMutableDictionary;
- import org.robovm.apple.foundation.NSObject;
- @@ -102,6 +102,8 @@ public class IOSApplication implements Application {
- /** The display scale factor (1.0f for normal; 2.0f to use retina coordinates/dimensions). */
- float displayScaleFactor;
- + private CGRect lastScreenBounds = null;
- +
- Array<Runnable> runnables = new Array<Runnable>();
- Array<Runnable> executedRunnables = new Array<Runnable>();
- Array<LifecycleListener> lifecycleListeners = new Array<LifecycleListener>();
- @@ -145,14 +147,11 @@ public class IOSApplication implements Application {
- }
- }
- - GL20 gl20 = new IOSGLES20();
- -
- - Gdx.gl = gl20;
- - Gdx.gl20 = gl20;
- -
- // setup libgdx
- this.input = new IOSInput(this);
- - this.graphics = new IOSGraphics(getBounds(null), scale, this, config, input, gl20);
- + this.graphics = new IOSGraphics(scale, this, config, input, config.useGL30);
- + Gdx.gl = Gdx.gl20 = graphics.gl20;
- + Gdx.gl30 = graphics.gl30;
- this.files = new IOSFiles();
- this.audio = new IOSAudio(config);
- this.net = new IOSNet(this);
- @@ -190,57 +189,55 @@ public class IOSApplication implements Application {
- return uiWindow;
- }
- - /** Returns our real display dimension based on screen orientation.
- + /** GL View spans whole screen, that is, even under the status bar. iOS can also rotate the screen, which is not handled
- + * consistently over iOS versions. This method returns, in pixels, rectangle in which libGDX draws.
- *
- - * @param viewController The view controller.
- - * @return Or real display dimension. */
- - CGSize getBounds (UIViewController viewController) {
- - // or screen size (always portrait)
- - CGSize bounds = UIScreen.getMainScreen().getApplicationFrame().getSize();
- -
- - // determine orientation and resulting width + height
- - UIInterfaceOrientation orientation;
- - if (viewController != null) {
- - orientation = viewController.getInterfaceOrientation();
- - } else if (config.orientationLandscape == config.orientationPortrait) {
- - /*
- - * if the app has orientation in any side then we can only check status bar orientation
- - */
- - orientation = uiApp.getStatusBarOrientation();
- - } else if (config.orientationLandscape) {// is landscape true and portrait false
- - orientation = UIInterfaceOrientation.LandscapeRight;
- - } else {// is portrait true and landscape false
- - orientation = UIInterfaceOrientation.Portrait;
- - }
- - int width;
- - int height;
- - switch (orientation) {
- + * @return dimensions of space we draw to, adjusted for device orientation */
- + protected CGRect getBounds () {
- + final CGRect screenBounds = UIScreen.getMainScreen().getBounds();
- + final CGRect statusBarFrame = uiApp.getStatusBarFrame();
- + final UIInterfaceOrientation statusBarOrientation = uiApp.getStatusBarOrientation();
- +
- + double statusBarHeight = Math.min(statusBarFrame.getWidth(), statusBarFrame.getHeight());
- +
- + double screenWidth = screenBounds.getWidth();
- + double screenHeight = screenBounds.getHeight();
- +
- + // Make sure that the orientation is consistent with ratios. Should be, but may not be on older iOS versions
- + switch (statusBarOrientation) {
- case LandscapeLeft:
- case LandscapeRight:
- - height = (int)bounds.getWidth();
- - width = (int)bounds.getHeight();
- - if (width < height) {
- - width = (int)bounds.getWidth();
- - height = (int)bounds.getHeight();
- + if (screenHeight > screenWidth) {
- + debug("IOSApplication", "Switching reported width and height (w=" + screenWidth + " h=" + screenHeight + ")");
- + double tmp = screenHeight;
- + // noinspection SuspiciousNameCombination
- + screenHeight = screenWidth;
- + screenWidth = tmp;
- }
- - break;
- - default:
- - // assume portrait
- - width = (int)bounds.getWidth();
- - height = (int)bounds.getHeight();
- }
- - Gdx.app.debug("IOSApplication", "Unscaled View: " + orientation.toString() + " " + width + "x" + height);
- -
- // update width/height depending on display scaling selected
- - width *= displayScaleFactor;
- - height *= displayScaleFactor;
- + screenWidth *= displayScaleFactor;
- + screenHeight *= displayScaleFactor;
- +
- + if (statusBarHeight != 0.0) {
- + debug("IOSApplication", "Status bar is visible (height = " + statusBarHeight + ")");
- + statusBarHeight *= displayScaleFactor;
- + screenHeight -= statusBarHeight;
- + } else {
- + debug("IOSApplication", "Status bar is not visible");
- + }
- +
- + debug("IOSApplication", "Total computed bounds are w=" + screenWidth + " h=" + screenHeight);
- - // log screen dimensions
- - Gdx.app.debug("IOSApplication", "View: " + orientation.toString() + " " + width + "x" + height);
- + return lastScreenBounds = new CGRect(0.0, statusBarHeight, screenWidth, screenHeight);
- + }
- - // return resulting view size (based on orientation)
- - return new CGSize(width, height);
- + protected CGRect getCachedBounds () {
- + if (lastScreenBounds == null)
- + return getBounds();
- + else
- + return lastScreenBounds;
- }
- final void didBecomeActive (UIApplication uiApp) {
- diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java
- index fb3a5f7..f813327 100644
- --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java
- +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSApplicationConfiguration.java
- @@ -92,4 +92,9 @@ public class IOSApplicationConfiguration {
- /** whether or not the onScreenKeyboard should be closed on return key **/
- public boolean keyboardCloseOnReturn = true;
- +
- + /** Experimental, whether to enable OpenGL ES 3 if supported. If not supported it will fall-back to OpenGL ES 2.0.
- + * When GL ES 3 is enabled, {@link com.badlogic.gdx.Gdx#gl30} can be used to access it's functionality.
- + * @deprecated this option is currently experimental and not yet fully supported, expect issues. */
- + @Deprecated public boolean useGL30 = false;
- }
- diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSDevice.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSDevice.java
- index f396183..470608d 100644
- --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSDevice.java
- +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSDevice.java
- @@ -17,12 +17,15 @@ public enum IOSDevice {
- IPHONE_5S_CDMA_GSM("iPhone6,2", 326),
- IPHONE_6_PLUS("iPhone7,1", 401),
- IPHONE_6("iPhone7,2", 326),
- + IPHONE_6S("iPhone8,1", 326),
- + IPHONE_6S_PLUS("iPhone8,2", 401),
- IPOD_TOUCH_1G("iPod1,1", 163),
- IPOD_TOUCH_2G("iPod2,1", 163),
- IPOD_TOUCH_3G("iPod3,1", 163),
- IPOD_TOUCH_4G("iPod4,1", 326),
- IPOD_TOUCH_5G("iPod5,1", 326),
- + IPOD_TOUCH_6G("iPod7,1", 326),
- IPAD("iPad1,1", 132),
- IPAD_3G("iPad1,2", 132),
- @@ -47,8 +50,14 @@ public enum IOSDevice {
- IPAD_MINI_RETINA_WIFI_CELLULAR_CN("iPad4,6", 326),
- IPAD_MINI_3_WIFI("iPad4,7", 326),
- IPAD_MINI_3_WIFI_CELLULAR("iPad4,8", 326),
- + IPAD_MINI_3_WIFI_CELLULAR_CN("iPad4,9", 326),
- + IPAD_MINI_4_WIFI("iPad5,1", 326),
- + IPAD_MINI_4_WIFI_CELLULAR("iPad5,2", 326),
- IPAD_MINI_AIR_2_WIFI("iPad5,3", 264),
- IPAD_MINI_AIR_2_WIFI_CELLULAR("iPad5,4", 264),
- + IPAD_PRO_WIFI("iPad6,7", 264),
- + IPAD_PRO("iPad6,8", 264),
- +
- SIMULATOR_32("i386", 264),
- SIMULATOR_64("x86_64", 264);
- diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGLES30.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGLES30.java
- new file mode 100644
- index 0000000..f40762d
- --- /dev/null
- +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGLES30.java
- @@ -0,0 +1,201 @@
- +package com.badlogic.gdx.backends.iosrobovm;
- +
- +import com.badlogic.gdx.graphics.GL30;
- +
- +import java.nio.Buffer;
- +import java.nio.FloatBuffer;
- +import java.nio.IntBuffer;
- +import java.nio.LongBuffer;
- +
- +public class IOSGLES30 extends IOSGLES20 implements GL30 {
- +
- + public IOSGLES30() {
- + init();
- + }
- +
- + private static native void init( );
- +
- + public native void glReadBuffer(int mode);
- +
- + public native void glDrawRangeElements(int mode, int start, int end, int count, int type, Buffer indices);
- +
- + public native void glDrawRangeElements(int mode, int start, int end, int count, int type, int offset);
- +
- + public native void glTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int format, int type, Buffer pixels);
- +
- + public native void glTexImage3D(int target, int level, int internalformat, int width, int height, int depth, int border, int format, int type, int offset);
- +
- + public native void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, Buffer pixels);
- +
- + public native void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, int offset);
- +
- + public native void glCopyTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height);
- +
- + public native void glGenQueries(int n, int[] ids, int offset);
- +
- + public native void glGenQueries(int n, IntBuffer ids);
- +
- + public native void glDeleteQueries(int n, int[] ids, int offset);
- +
- + public native void glDeleteQueries(int n, IntBuffer ids);
- +
- + public native boolean glIsQuery(int id);
- +
- + public native void glBeginQuery(int target, int id);
- +
- + public native void glEndQuery(int target);
- +
- + public native void glGetQueryiv(int target, int pname, IntBuffer params);
- +
- + public native void glGetQueryObjectuiv(int id, int pname, IntBuffer params);
- +
- + public native boolean glUnmapBuffer(int target);
- +
- + public native Buffer glGetBufferPointerv(int target, int pname);
- +
- + public native void glDrawBuffers(int n, IntBuffer bufs);
- +
- + public native void glUniformMatrix2x3fv(int location, int count, boolean transpose, FloatBuffer value);
- +
- + public native void glUniformMatrix3x2fv(int location, int count, boolean transpose, FloatBuffer value);
- +
- + public native void glUniformMatrix2x4fv(int location, int count, boolean transpose, FloatBuffer value);
- +
- + public native void glUniformMatrix4x2fv(int location, int count, boolean transpose, FloatBuffer value);
- +
- + public native void glUniformMatrix3x4fv(int location, int count, boolean transpose, FloatBuffer value);
- +
- + public native void glUniformMatrix4x3fv(int location, int count, boolean transpose, FloatBuffer value);
- +
- + public native void glBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, int mask, int filter);
- +
- + public native void glRenderbufferStorageMultisample(int target, int samples, int internalformat, int width, int height);
- +
- + public native void glFramebufferTextureLayer(int target, int attachment, int texture, int level, int layer);
- +
- + public native void glFlushMappedBufferRange(int target, int offset, int length);
- +
- + public native void glBindVertexArray(int array);
- +
- + public native void glDeleteVertexArrays(int n, int[] arrays, int offset);
- +
- + public native void glDeleteVertexArrays(int n, IntBuffer arrays);
- +
- + public native void glGenVertexArrays(int n, int[] arrays, int offset);
- +
- + public native void glGenVertexArrays(int n, IntBuffer arrays);
- +
- + public native boolean glIsVertexArray(int array);
- +
- + public native void glBeginTransformFeedback(int primitiveMode);
- +
- + public native void glEndTransformFeedback();
- +
- + public native void glBindBufferRange(int target, int index, int buffer, int offset, int size);
- +
- + public native void glBindBufferBase(int target, int index, int buffer);
- +
- + public native void glTransformFeedbackVaryings(int program, String[] varyings, int bufferMode);
- +
- + public native void glVertexAttribIPointer(int index, int size, int type, int stride, int offset);
- +
- + public native void glGetVertexAttribIiv(int index, int pname, IntBuffer params);
- +
- + public native void glGetVertexAttribIuiv(int index, int pname, IntBuffer params);
- +
- + public native void glVertexAttribI4i(int index, int x, int y, int z, int w);
- +
- + public native void glVertexAttribI4ui(int index, int x, int y, int z, int w);
- +
- + public native void glGetUniformuiv(int program, int location, IntBuffer params);
- +
- + public native int glGetFragDataLocation(int program, String name);
- +
- + public native void glUniform1uiv(int location, int count, IntBuffer value);
- +
- + public native void glUniform3uiv(int location, int count, IntBuffer value);
- +
- + public native void glUniform4uiv(int location, int count, IntBuffer value);
- +
- + public native void glClearBufferiv(int buffer, int drawbuffer, IntBuffer value);
- +
- + public native void glClearBufferuiv(int buffer, int drawbuffer, IntBuffer value);
- +
- + public native void glClearBufferfv(int buffer, int drawbuffer, FloatBuffer value);
- +
- + public native void glClearBufferfi(int buffer, int drawbuffer, float depth, int stencil);
- +
- + public native String glGetStringi(int name, int index);
- +
- + public native void glCopyBufferSubData(int readTarget, int writeTarget, int readOffset, int writeOffset, int size);
- +
- + public native void glGetUniformIndices(int program, String[] uniformNames, IntBuffer uniformIndices);
- +
- + public native void glGetActiveUniformsiv(int program, int uniformCount, IntBuffer uniformIndices, int pname, IntBuffer params);
- +
- + public native int glGetUniformBlockIndex(int program, String uniformBlockName);
- +
- + public native void glGetActiveUniformBlockiv(int program, int uniformBlockIndex, int pname, IntBuffer params);
- +
- + public native void glGetActiveUniformBlockName(int program, int uniformBlockIndex, Buffer length, Buffer uniformBlockName);
- +
- + public native String glGetActiveUniformBlockName(int program, int uniformBlockIndex);
- +
- + public native void glUniformBlockBinding(int program, int uniformBlockIndex, int uniformBlockBinding);
- +
- + public native void glDrawArraysInstanced(int mode, int first, int count, int instanceCount);
- +
- + public native void glDrawElementsInstanced(int mode, int count, int type, int indicesOffset, int instanceCount);
- +
- + public native void glGetInteger64v(int pname, LongBuffer params);
- +
- + public native void glGetBufferParameteri64v(int target, int pname, LongBuffer params);
- +
- + public native void glGenSamplers(int count, int[] samplers, int offset);
- +
- + public native void glGenSamplers(int count, IntBuffer samplers);
- +
- + public native void glDeleteSamplers(int count, int[] samplers, int offset);
- +
- + public native void glDeleteSamplers(int count, IntBuffer samplers);
- +
- + public native boolean glIsSampler(int sampler);
- +
- + public native void glBindSampler(int unit, int sampler);
- +
- + public native void glSamplerParameteri(int sampler, int pname, int param);
- +
- + public native void glSamplerParameteriv(int sampler, int pname, IntBuffer param);
- +
- + public native void glSamplerParameterf(int sampler, int pname, float param);
- +
- + public native void glSamplerParameterfv(int sampler, int pname, FloatBuffer param);
- +
- + public native void glGetSamplerParameteriv(int sampler, int pname, IntBuffer params);
- +
- + public native void glGetSamplerParameterfv(int sampler, int pname, FloatBuffer params);
- +
- + public native void glVertexAttribDivisor(int index, int divisor);
- +
- + public native void glBindTransformFeedback(int target, int id);
- +
- + public native void glDeleteTransformFeedbacks(int n, int[] ids, int offset);
- +
- + public native void glDeleteTransformFeedbacks(int n, IntBuffer ids);
- +
- + public native void glGenTransformFeedbacks(int n, int[] ids, int offset);
- +
- + public native void glGenTransformFeedbacks(int n, IntBuffer ids);
- +
- + public native boolean glIsTransformFeedback(int id);
- +
- + public native void glPauseTransformFeedback();
- +
- + public native void glResumeTransformFeedback();
- +
- + public native void glProgramParameteri(int program, int pname, int value);
- +
- + public native void glInvalidateFramebuffer(int target, int numAttachments, IntBuffer attachments);
- +
- + public native void glInvalidateSubFramebuffer(int target, int numAttachments, IntBuffer attachments, int x, int y, int width, int height);
- +}
- \ No newline at end of file
- diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java
- index a26dae7..cc81fa1 100644
- --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java
- +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSGraphics.java
- @@ -16,9 +16,7 @@
- package com.badlogic.gdx.backends.iosrobovm;
- -import org.robovm.apple.coregraphics.CGPoint;
- import org.robovm.apple.coregraphics.CGRect;
- -import org.robovm.apple.coregraphics.CGSize;
- import org.robovm.apple.foundation.NSObject;
- import org.robovm.apple.glkit.GLKView;
- import org.robovm.apple.glkit.GLKViewController;
- @@ -47,6 +45,7 @@ import com.badlogic.gdx.graphics.Cursor;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.GL30;
- import com.badlogic.gdx.graphics.Pixmap;
- +import com.badlogic.gdx.graphics.Cursor.SystemCursor;
- import com.badlogic.gdx.utils.Array;
- public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate, GLKViewControllerDelegate {
- @@ -77,21 +76,6 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- }
- @Override
- - public void didRotate (UIInterfaceOrientation orientation) {
- - super.didRotate(orientation);
- - // get the view size and update graphics
- - // FIXME: supporting BOTH (landscape+portrait at same time) is
- - // currently not working correctly (needs fix)
- - // FIXME screen orientation needs to be stored for
- - // Input#getNativeOrientation
- - CGSize bounds = app.getBounds(this);
- - graphics.width = (int)bounds.getWidth();
- - graphics.height = (int)bounds.getHeight();
- - graphics.makeCurrent();
- - app.listener.resize(graphics.width, graphics.height);
- - }
- -
- - @Override
- public UIInterfaceOrientationMask getSupportedInterfaceOrientations () {
- long mask = 0;
- if (app.config.orientationLandscape) {
- @@ -120,6 +104,17 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- }
- }
- + @Override
- + public void viewDidLayoutSubviews () {
- + super.viewDidLayoutSubviews();
- + // get the view size and update graphics
- + CGRect bounds = app.getBounds();
- + graphics.width = (int)bounds.getWidth();
- + graphics.height = (int)bounds.getHeight();
- + graphics.makeCurrent();
- + app.listener.resize(graphics.width, graphics.height);
- + }
- +
- @Callback
- @BindSelector("shouldAutorotateToInterfaceOrientation:")
- private static boolean shouldAutorotateToInterfaceOrientation (IOSUIViewController self, Selector sel,
- @@ -138,6 +133,7 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- IOSApplication app;
- IOSInput input;
- GL20 gl20;
- + GL30 gl30;
- int width;
- int height;
- long lastFrameTime;
- @@ -164,36 +160,48 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- GLKView view;
- IOSUIViewController viewController;
- - public IOSGraphics (CGSize bounds, float scale, IOSApplication app, IOSApplicationConfiguration config, IOSInput input,
- - GL20 gl20) {
- + public IOSGraphics (float scale, IOSApplication app, IOSApplicationConfiguration config, IOSInput input, boolean useGLES30) {
- this.config = config;
- +
- + final CGRect bounds = app.getBounds();
- // setup view and OpenGL
- width = (int)bounds.getWidth();
- height = (int)bounds.getHeight();
- - app.debug(tag, bounds.getWidth() + "x" + bounds.getHeight() + ", " + scale);
- - this.gl20 = gl20;
- - context = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
- + if (useGLES30) {
- + context = new EAGLContext(EAGLRenderingAPI.OpenGLES3);
- + if (context != null)
- + gl20 = gl30 = new IOSGLES30();
- + else
- + Gdx.app.log("IOGraphics", "OpenGL ES 3.0 not supported, falling back on 2.0");
- + }
- + if (context == null) {
- + context = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
- + gl20 = new IOSGLES20();
- + gl30 = null;
- + }
- +
- - view = new GLKView(new CGRect(new CGPoint(0, 0), bounds), context) {
- +
- + view = new GLKView(new CGRect(0, 0, bounds.getWidth(), bounds.getHeight()), context) {
- @Method(selector = "touchesBegan:withEvent:")
- public void touchesBegan (@Pointer long touches, UIEvent event) {
- - IOSGraphics.this.input.touchDown(touches, event);
- + IOSGraphics.this.input.onTouch(touches);
- }
- @Method(selector = "touchesCancelled:withEvent:")
- public void touchesCancelled (@Pointer long touches, UIEvent event) {
- - IOSGraphics.this.input.touchUp(touches, event);
- + IOSGraphics.this.input.onTouch(touches);
- }
- @Method(selector = "touchesEnded:withEvent:")
- public void touchesEnded (@Pointer long touches, UIEvent event) {
- - IOSGraphics.this.input.touchUp(touches, event);
- + IOSGraphics.this.input.onTouch(touches);
- }
- @Method(selector = "touchesMoved:withEvent:")
- public void touchesMoved (@Pointer long touches, UIEvent event) {
- - IOSGraphics.this.input.touchMoved(touches, event);
- + IOSGraphics.this.input.onTouch(touches);
- }
- @Override
- @@ -240,7 +248,6 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- samples = 4;
- }
- bufferFormat = new BufferFormat(r, g, b, a, depth, stencil, samples, false);
- - this.gl20 = gl20;
- String machineString = HWMachine.getMachineString();
- IOSDevice device = IOSDevice.getDevice(machineString);
- @@ -355,6 +362,16 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- public int getHeight () {
- return height;
- }
- +
- + @Override
- + public int getBackBufferWidth() {
- + return width;
- + }
- +
- + @Override
- + public int getBackBufferHeight() {
- + return height;
- + }
- @Override
- public float getDeltaTime () {
- @@ -408,28 +425,47 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- @Override
- public DisplayMode[] getDisplayModes () {
- - return new DisplayMode[] {getDesktopDisplayMode()};
- + return new DisplayMode[] {getDisplayMode()};
- }
- @Override
- - public DisplayMode getDesktopDisplayMode () {
- + public DisplayMode getDisplayMode () {
- return new IOSDisplayMode(getWidth(), getHeight(), config.preferredFramesPerSecond, bufferFormat.r + bufferFormat.g
- + bufferFormat.b + bufferFormat.a);
- }
- +
- + @Override
- + public Monitor getPrimaryMonitor() {
- + return new IOSMonitor(0, 0, "Primary Monitor");
- + }
- - private class IOSDisplayMode extends DisplayMode {
- - protected IOSDisplayMode (int width, int height, int refreshRate, int bitsPerPixel) {
- - super(width, height, refreshRate, bitsPerPixel);
- - }
- + @Override
- + public Monitor getMonitor() {
- + return getPrimaryMonitor();
- + }
- +
- + @Override
- + public Monitor[] getMonitors() {
- + return new Monitor[] { getPrimaryMonitor() };
- + }
- +
- + @Override
- + public DisplayMode[] getDisplayModes(Monitor monitor) {
- + return getDisplayModes();
- + }
- +
- + @Override
- + public DisplayMode getDisplayMode(Monitor monitor) {
- + return getDisplayMode();
- }
- @Override
- - public boolean setDisplayMode (DisplayMode displayMode) {
- + public boolean setFullscreenMode (DisplayMode displayMode) {
- return false;
- }
- @Override
- - public boolean setDisplayMode (int width, int height, boolean fullscreen) {
- + public boolean setWindowedMode (int width, int height) {
- return false;
- }
- @@ -502,4 +538,20 @@ public class IOSGraphics extends NSObject implements Graphics, GLKViewDelegate,
- @Override
- public void setCursor (Cursor cursor) {
- }
- +
- + @Override
- + public void setSystemCursor (SystemCursor systemCursor) {
- + }
- +
- + private class IOSDisplayMode extends DisplayMode {
- + protected IOSDisplayMode (int width, int height, int refreshRate, int bitsPerPixel) {
- + super(width, height, refreshRate, bitsPerPixel);
- + }
- + }
- +
- + private class IOSMonitor extends Monitor {
- + protected IOSMonitor(int virtualX, int virtualY, String name) {
- + super(virtualX, virtualY, name);
- + }
- + }
- }
- diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSInput.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSInput.java
- index 630bbb1..92add30 100644
- --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSInput.java
- +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSInput.java
- @@ -26,10 +26,7 @@ import org.robovm.apple.uikit.UIAlertView;
- import org.robovm.apple.uikit.UIAlertViewDelegate;
- import org.robovm.apple.uikit.UIAlertViewDelegateAdapter;
- import org.robovm.apple.uikit.UIAlertViewStyle;
- -import org.robovm.apple.uikit.UIApplication;
- import org.robovm.apple.uikit.UIDevice;
- -import org.robovm.apple.uikit.UIEvent;
- -import org.robovm.apple.uikit.UIInterfaceOrientation;
- import org.robovm.apple.uikit.UIKeyboardType;
- import org.robovm.apple.uikit.UIReturnKeyType;
- import org.robovm.apple.uikit.UITextAutocapitalizationType;
- @@ -53,7 +50,6 @@ import com.badlogic.gdx.backends.iosrobovm.custom.UIAcceleration;
- import com.badlogic.gdx.backends.iosrobovm.custom.UIAccelerometer;
- import com.badlogic.gdx.backends.iosrobovm.custom.UIAccelerometerDelegate;
- import com.badlogic.gdx.backends.iosrobovm.custom.UIAccelerometerDelegateAdapter;
- -import com.badlogic.gdx.math.MathUtils;
- import com.badlogic.gdx.utils.Array;
- import com.badlogic.gdx.utils.GdxRuntimeException;
- import com.badlogic.gdx.utils.Pool;
- @@ -246,6 +242,7 @@ public class IOSInput implements Input {
- public float getAccelerometerZ () {
- return acceleration[2];
- }
- +
- @Override
- public float getAzimuth () {
- @@ -534,6 +531,11 @@ public class IOSInput implements Input {
- @Override
- public void setCatchMenuKey (boolean catchMenu) {
- }
- +
- + @Override
- + public boolean isCatchMenuKey() {
- + return false;
- + }
- @Override
- public void setInputProcessor (InputProcessor processor) {
- @@ -557,19 +559,29 @@ public class IOSInput implements Input {
- @Override
- public int getRotation () {
- - UIInterfaceOrientation orientation = app.graphics.viewController != null ? app.graphics.viewController
- - .getInterfaceOrientation() : UIApplication.getSharedApplication().getStatusBarOrientation();
- // we measure orientation counter clockwise, just like on Android
- - if (orientation == UIInterfaceOrientation.Portrait) return 0;
- - if (orientation == UIInterfaceOrientation.LandscapeLeft) return 270;
- - if (orientation == UIInterfaceOrientation.PortraitUpsideDown) return 180;
- - if (orientation == UIInterfaceOrientation.LandscapeRight) return 90;
- - return 0;
- + switch (app.uiApp.getStatusBarOrientation()) {
- + case LandscapeLeft:
- + return 270;
- + case PortraitUpsideDown:
- + return 180;
- + case LandscapeRight:
- + return 90;
- + case Portrait:
- + default:
- + return 0;
- + }
- }
- @Override
- public Orientation getNativeOrientation () {
- - return Orientation.Portrait;
- + switch (app.uiApp.getStatusBarOrientation()) {
- + case LandscapeLeft:
- + case LandscapeRight:
- + return Orientation.Landscape;
- + default:
- + return Orientation.Portrait;
- + }
- }
- @Override
- @@ -585,18 +597,8 @@ public class IOSInput implements Input {
- public void setCursorPosition (int x, int y) {
- }
- - public void touchDown (long touches, UIEvent event) {
- - toTouchEvents(touches, event);
- - Gdx.graphics.requestRendering();
- - }
- -
- - public void touchUp (long touches, UIEvent event) {
- - toTouchEvents(touches, event);
- - Gdx.graphics.requestRendering();
- - }
- -
- - public void touchMoved (long touches, UIEvent event) {
- - toTouchEvents(touches, event);
- + protected void onTouch (long touches) {
- + toTouchEvents(touches);
- Gdx.graphics.requestRendering();
- }
- @@ -653,18 +655,27 @@ public class IOSInput implements Input {
- public static native @MachineSizedUInt long count (@Pointer long thiz);
- }
- - private void toTouchEvents (long touches, UIEvent uiEvent) {
- + private void toTouchEvents (long touches) {
- long array = NSSetExtensions.allObjects(touches);
- int length = (int)NSArrayExtensions.count(array);
- for (int i = 0; i < length; i++) {
- long touchHandle = NSArrayExtensions.objectAtIndex$(array, i);
- UITouch touch = UI_TOUCH_WRAPPER.wrap(touchHandle);
- - CGPoint loc = touch.getLocationInView(touch.getView());
- + final int locX, locY;
- + // Get and map the location to our drawing space
- + {
- + CGPoint loc = touch.getLocationInView(touch.getWindow());
- + final CGRect bounds = app.getCachedBounds();
- + locX = (int)(loc.getX() * app.displayScaleFactor - bounds.getMinX());
- + locY = (int)(loc.getY() * app.displayScaleFactor - bounds.getMinY());
- + // app.debug("IOSInput","pos= "+loc+" bounds= "+bounds+" x= "+locX+" locY= "+locY);
- + }
- +
- synchronized (touchEvents) {
- UITouchPhase phase = touch.getPhase();
- TouchEvent event = touchEventPool.obtain();
- - event.x = (int)(loc.getX() * app.displayScaleFactor);
- - event.y = (int)(loc.getY() * app.displayScaleFactor);
- + event.x = locX;
- + event.y = locY;
- event.phase = phase;
- event.timestamp = (long)(touch.getTimestamp() * 1000000000);
- touchEvents.add(event);
- @@ -706,4 +717,24 @@ public class IOSInput implements Input {
- int x, y;
- int pointer;
- }
- +
- + @Override
- + public float getGyroscopeX() {
- + // TODO Auto-generated method stub
- + return 0;
- + }
- +
- + @Override
- + public float getGyroscopeY() {
- + // TODO Auto-generated method stub
- + return 0;
- + }
- +
- + @Override
- + public float getGyroscopeZ() {
- + // TODO Auto-generated method stub
- + return 0;
- + }
- +
- +
- }
- diff --git a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSSound.java b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSSound.java
- index a0440ce..a25b276 100644
- --- a/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSSound.java
- +++ b/backends/gdx-backend-robovm/src/com/badlogic/gdx/backends/iosrobovm/IOSSound.java
- @@ -134,11 +134,6 @@ public class IOSSound implements Sound {
- }
- @Override
- - public void setPriority (long soundId, int priority) {
- - // TODO Auto-generated method stub
- - }
- -
- - @Override
- public void pause () {
- ALSource source;
- for (int i = 0; i < streamIds.size; i++) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement