Android: Glbasic not updating surface when auto rotated (still in 11.171).

Previous topic - Next topic

spacefractal

Im looking into this soon, but its might been tolate for Greedy Moues due its complexe code. By now its simply just pause when I roate my device and then its hanging (and AUTOPAUSE TRUE/FALSE diddent matter). Howover nothing problem to play the game only in landscape mode, its works fine.

Howover its better looking this issue with a little new project. Then I report soon what happens with the little new project. The first oddie is really its seen its start with 90 degree wrong in startup (the box example here start from top right rather than top left as its should). This could been the main issue, etc its have some orentation confuction. Howover I invistate later today.

Code (glbasic) Select


LOCAL C=0
REPEAT
FOR i=0 TO 360 STEP 4
DRAWRECT 0, 0, i, i, RGB(100, 100, 100)
  SHOWSCREEN
  C=C+1
  IF C=200
  NETWEBEND "http://www.glbasic.com"
ENDIF
MOUSESTATE mx, my, mba, mbb
IF (mba=1 OR mbb=1) AND mx<20 AND my<20 THEN END
NEXT
UNTIL mba=1000
MOUSEWAIT
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

I have looked into more just now. Its a diffesivt issues in glbasic.

By now I use this manifest:

Code (glbasic) Select

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.unmapcom.rotosprite"
      android:installLocation="preferExternal"
      android:versionCode="1"
      android:versionName="0.001">
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<supports-screens android:resizeable="false"
  android:smallScreens="true"
  android:normalScreens="true"
  android:largeScreens="true"
  android:anyDensity="true" />
    <application android:label="@string/app_name" android:icon="@drawable/icon" android:debuggable="false">
        <activity android:name="org.libsdl.app.SDLActivity"
android:label="@string/app_name"
android:screenOrientation="unspecified"
android:configChanges="keyboard|keyboardHidden|orientation">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>


and doing this code:
Code (glbasic) Select

AUTOPAUSE FALSE
ALLOWESCAPE FALSE

LOCAL C=0
SETCURRENTDIR("Media")
LOADSPRITE "block.png",0
REPEAT
FOR i=0 TO 360 STEP 4
GETSCREENSIZE x, y
DRAWRECT 0, 0, x, y, RGB(250, 250, 0)
DRAWSPRITE 0, x-100, y-100
DRAWSPRITE 0, 20, 20
DRAWSPRITE 0, x-100, 20
DRAWSPRITE 0, 20, y-100
DRAWRECT x/2-i/2, y/2-i/2, i, i, RGB(100, 100, 100)

DRAWRECT 10, y/2-i/8, i/4, i/4, RGB(100, 100, 100)
  SHOWSCREEN
  C=C+1
MOUSESTATE mx, my, mba, mbb
IF (mba=1 OR mbb=1) AND mx<20 AND my<20 THEN END
NEXT
UNTIL mba=1000
MOUSEWAIT



  • Then when I invoke that, the screen is rotated 90 degree wrong on my HP Touchpad (its should rotate correct way in startup, elsewise its will confusing). EDIT: This can been fixed by invoke SETORIENTATION 0 in the startup. Odd, that should been happens automatic?
  • When I rotate my device to the another orientation, its simply onPause() and then quit. Still not sure why.

Also here was the log output:
Code (glbasic) Select

I/SDL     ( 7018): ---------------------------------------------
I/SDL     ( 7018): ---               restart                 ---
I/SDL     ( 7018): ---------------------------------------------
I/SDL     ( 7018): onCreate
I/glbasic ( 7018): external files dir is /data/data/com.unmapcom.rotosprite/file
s
I/glbasic ( 7018): external storage /mnt/sdcard/Download
I/glbasic ( 7018): copy assets starts
I/glbasic ( 7018): assets found, copying...
I/glbasic ( 7018): updating assets...
I/glbasic ( 7018): Media is a directory
I/glbasic ( 7018): updating assets .. sleep
I/glbasic ( 7018): updating assets is done
I/glbasic ( 7018):    onCreate done
I/SDL     ( 7018): onResume()
I/SDL     ( 7018):     onResume done
I/SDL     ( 7018): ceateEGLSurface
I/SDL     ( 7018): surfaceChanged()
I/SDL     ( 7018): pixel format RGB_565
I/SDL     ( 7018): hint screensize to glb
I/SDL     ( 7018): SDL_Android_Init()
I/glbasic ( 7018): timer
I/glbasic ( 7018): rbow
I/glbasic ( 7018): rbow init
I/SDL     ( 7018): [STUB] GL_SetSwapInterval
I/glbasic ( 7018): SDL_init video
I/glbasic ( 7018): SDL_GetVideoInfo = 1024x720 @ 16 bpp
I/glbasic ( 7018): Requested SDL_OPENGL = 67108864
I/glbasic ( 7018): set up SDL for OpenGL-ES mode
I/glbasic ( 7018): Setting video mode: 1024x720x16 fl=4800000
I/SDL     ( 7018): [STUB] GL_LoadLibrary
I/SDL     ( 7018): ceateGLContext
I/SDL     ( 7018): initEGL 1.1
I/SDL     ( 7018): ceateEGLSurface
I/SDL     ( 7018): ceateEGLContext
I/glbasic ( 7018): SDL_SetVideoMode seems to be 1
I/glbasic ( 7018): get accurate timer - 1st call
I/glbasic ( 7018): flip - 1st call
I/glbasic ( 7018): BGRA ext supported
I/glbasic ( 7018): Texture size limit: 4096
I/glbasic ( 7018): init fbo
I/glbasic ( 7018): 2D VP
I/glbasic ( 7018): OGRB init [OK]
I/glbasic ( 7018): Cptn
I/glbasic ( 7018): Network
I/glbasic ( 7018): Input
I/glbasic ( 7018): Window mode
I/glbasic ( 7018): Create DXin
I/glbasic ( 7018): sdl_grab
I/glbasic ( 7018): reptr
I/glbasic ( 7018): getexe
I/glbasic ( 7018): cd
I/glbasic ( 7018): set cdir to: /data/data/com.unmapcom.rotosprite
I/glbasic ( 7018): exepath=curdir= /data/data/com.unmapcom.rotosprite
I/glbasic ( 7018): shoeboxing...
I/glbasic ( 7018): init gettimer
I/glbasic ( 7018): clear screen
I/glbasic ( 7018): flip
I/glbasic ( 7018): mk2D
I/SDL     ( 7018): query glb_asset_copy_done: true
I/glbasic ( 7018): finding font...
I/glbasic ( 7018): set cdir to: files
I/glbasic ( 7018): Init Finalized
I/glbasic ( 7018): set cdir to: Media
I/SDL     ( 7018): onPause()
I/SDL     ( 7018): glbasicOnPause(1)
I/SDL     ( 7018): super.onPause
I/SDL     ( 7018):    onPause done
I/glbasic ( 7018): Shut down GLB
I/glbasic ( 7018): glb is shut down
I/SDL     ( 7018): [STUB] GL_UnloadLibrary


The above was happens on my HP Touchpad with Android 4.

PS. I have before got hints before, even its not worked 100%. Howover I have no problems using a fixed orintation in my game.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

When you read "shut down glb". That's on purpose. Like END command.

spacefractal

"Shut Down GLB" should not been happens on purpose after onPause() is invoked (when AUTOPAUSE set to FALSE), so its a bug. I did not called a "Shut Down GLB" there.....
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

Looked into this today after fixed the Java issue. Its seen the shutdown issue was done when you using TargetAPI level 13 or higher, but if you set TargetAPI to 12 then glBasic does NOT quit but its got it hint as its should.

But its still some issues left. SETSCREEN is still not working correctly after the hint and X/Y is still been swapped on the other orientation.

Screen might start 90 degree wrong in startup, but that got fixed by SETORIENTATION 0 (which moved down for test), but after the hint then thing goes wrong (even I set SETORIENTATION 0).

Here the code (which also inclue some JAVACALL tests):

Code (glbasic) Select


AUTOPAUSE FALSE
ALLOWESCAPE FALSE

STDOUT "IMPORT"
?IFDEF ANDROID
IMPORT "C" const char* android_JAVACALL(const char* string)
?ENDIF

LOCAL test$=android_JAVACALL("test")
STDOUT "test: "+test$

GETDESKTOPSIZE Xcreen, Yscreen
SETSCREEN Xcreen, Ycreen, 1

LOCAL C=0
Check_File("block.png")
SETCURRENTDIR("Media")
LOADSPRITE "block.png",0
REPEAT
FOR i=0 TO 360 STEP 4
GETSCREENSIZE x, y
DRAWRECT 0, 0, x, y, RGB(250, 250, 0)
DRAWSPRITE 0, x-100, y-100
DRAWSPRITE 0, 20, 20
DRAWSPRITE 0, x-100, 20
DRAWSPRITE 0, 20, y-100
DRAWRECT x/2-i/2, y/2-i/2, i, i, RGB(100, 100, 100)
DRAWRECT 10, y/2-i/8, i/4, i/4, RGB(100, 100, 100)
  SHOWSCREEN
  C=C+1
MOUSESTATE mx, my, mba, mbb
IF (mba=1 OR mbb=1) AND mx<20 AND my<20 THEN END
GETDESKTOPSIZE xDesk, yDesk
GETSCREENSIZE Xcreen, Yscreen
IF C=50 THEN SETORIENTATION 0

IF C=100
C=0
STDOUT xDesk+" "+yDesk+" :: "+Xcreen+" "+Yscreen
IF xDesk<>Xcreen AND yDesk<>Yscreen
SETSCREEN xDesk, yDesk, 1
ENDIF
ENDIF
NEXT
UNTIL mba=1000

FUNCTION CallJava$: Args$
LOCAL result$
?IFDEF ANDROID
result$=android_JAVACALL(Args$)
STDOUT "calljava: "+Args$+" "+result$
RETURN result$
?ENDIF
RETURN ""
ENDFUNCTION

FUNCTION Check_File: File$
LOCAL fileapksize=CallJava$("size:"+File$)
STDOUT "Check Filesize on "+File$+" :: "+fileapksize
LOCAL filelocalsize=GETFILESIZE(File$);

IF fileapksize<1 OR fileapksize<>filelocalsize
CallJava$("copy:"+File$)
ENDIF
ENDFUNCTION


here is the output I got:
Code (glbasic) Select

I/SDL     (18573): ---------------------------------------------
I/SDL     (18573): ---               restart                 ---
I/SDL     (18573): ---------------------------------------------
I/SDL     (18573): onCreate
I/glbasic (18573): external files dir is /data/data/com.unmapcom.rotosprite/file
s
I/glbasic (18573): external storage /mnt/sdcard/Download
I/glbasic (18573): test 2
I/glbasic (18573): test
I/glbasic (18573):    onCreate done
I/SDL     (18573): glbasicOnPause(0)
I/SDL     (18573):     onResume done
I/SDL     (18573): ceateEGLSurface
I/SDL     (18573): surfaceChanged()
I/SDL     (18573): pixel format RGB_565
I/SDL     (18573): hint screensize to glb
I/SDL     (18573): SDL_Android_Init()
I/glbasic (18573): timer
I/glbasic (18573): rbow
I/glbasic (18573): rbow init
I/SDL     (18573): [STUB] GL_SetSwapInterval
I/glbasic (18573): SDL_init video
I/glbasic (18573): SDL_GetVideoInfo = 1024x720 @ 16 bpp
I/glbasic (18573): Requested SDL_OPENGL = 67108864
I/glbasic (18573): set up SDL for OpenGL-ES mode
I/glbasic (18573): Setting video mode: 1024x720x16 fl=4800000
I/SDL     (18573): [STUB] GL_LoadLibrary
I/SDL     (18573): ceateGLContext
I/SDL     (18573): initEGL 1.1
I/SDL     (18573): ceateEGLSurface
I/SDL     (18573): ceateEGLContext
I/glbasic (18573): SDL_SetVideoMode seems to be 1
I/glbasic (18573): get accurate timer - 1st call
I/glbasic (18573): flip - 1st call
I/glbasic (18573): BGRA ext supported
I/glbasic (18573): Texture size limit: 4096
I/glbasic (18573): init fbo
I/glbasic (18573): 2D VP
I/glbasic (18573): OGRB init [OK]
I/glbasic (18573): Cptn
I/glbasic (18573): Network
I/glbasic (18573): Input
I/glbasic (18573): Window mode
I/glbasic (18573): Create DXin
I/glbasic (18573): sdl_grab
I/glbasic (18573): reptr
I/glbasic (18573): getexe
I/glbasic (18573): cd
I/glbasic (18573): set cdir to: /data/data/com.unmapcom.rotosprite
I/glbasic (18573): exepath=curdir= /data/data/com.unmapcom.rotosprite
I/glbasic (18573): shoeboxing...
I/glbasic (18573): init gettimer
I/glbasic (18573): clear screen
I/glbasic (18573): flip
I/glbasic (18573): mk2D
I/glbasic (18573): finding font...
I/glbasic (18573): set cdir to: files
I/glbasic (18573): Init Finalized
I/glbasic (18573): IMPORT
I/glbasic (18573): calltest
I/glbasic (18573): test: This is Working String
I/glbasic (18573): Rbow::SetScreen( 1024,0)
I/glbasic (18573): calltest
I/glbasic (18573): Media/block.png is a file, reading...
I/glbasic (18573): calljava: size:block.png 8773
I/glbasic (18573): Check Filesize on block.png :: 8773
I/glbasic (18573): calltest
I/glbasic (18573): calljava: copy:block.png
I/glbasic (18573): set cdir to: Media
I/glbasic (18573): 1024 720 :: 1024 720
I/glbasic (18573): 1024 720 :: 1024 720
I/SDL     (18573): surfaceChanged()
I/SDL     (18573): pixel format RGB_565
I/SDL     (18573): hint screensize to glb
I/glbasic (18573): 768 976 :: 1024 720
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/SDL     (18573): surfaceChanged()
I/SDL     (18573): pixel format RGB_565
I/SDL     (18573): hint screensize to glb
I/glbasic (18573): 1024 720 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 1024,720)
I/glbasic (18573): 1024 720 :: 1024 720
I/glbasic (18573): 1024 720 :: 1024 720
I/glbasic (18573): 1024 720 :: 1024 720
I/glbasic (18573): 1024 720 :: 1024 720
I/glbasic (18573): 1024 720 :: 1024 720
I/SDL     (18573): surfaceChanged()
I/SDL     (18573): pixel format RGB_565
I/SDL     (18573): hint screensize to glb
I/glbasic (18573): 768 976 :: 1024 720
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/glbasic (18573): 768 976 :: 976 768
I/glbasic (18573): Rbow::SetScreen( 768,976)
I/SDL     (18573): glbasicOnPause(1)
I/SDL     (18573): super.onPause
I/SDL     (18573):    onPause done
I/SDL     (18573): surfaceDestroyed()


As you see X and Y is still swapped when I rotate 90 degree from start orientation. Rotating 180 degree works fine.

Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

It's fixed. I can't believe it.

When you set your manifest to
Code (glbasic) Select

...
android:screenOrientation="sensor"
android:configChanges="orientation|keyboardHidden"


then the GETSCREENSIZE will return 1024x768 or 768x1024 depending on the device orientation. The menu bar will be rotated correctly. SETORIENTATION will stick to 0. If you want your app to always be landscape, you have to use setorientation manually.
Is that what's expected?





johnparker29

I looking what its happens in this bug in the other day. Its actuelly really essential for ICS mobile phones as well platforms, due they often have a touchbar in the end or to right and here its should been system centered spinning, not application.

spacefractal

I have removed 2 post to avoid some confuction and instead I write this one (really sorry about that).

android:screenOrientation="sensor":
- The hint system works and the system is orientation correct (as long TargetSDK is 12 or lower). The orientation is wrong, and resoulution by SETSCREEN is XY swapped. That happens on my HP Touchpad. I guess that xy swap bug is just fixed by Gernot.

android:screenOrientation="landscape": (with SETORIENTATION 0)
- Set Orientation to 0 works on landscape devices (HP Touchpad), but fail on a loan HTC Sense.

android:screenOrientation="portrait": (with SETORIENTATION 0)
- Works nice on HTC Sense, but fail on HP TouchPad.

To fix as I known:
- SETORIENTATION should set the value from Java's display.getOrientation(). That is really important! That fixed both Portrait issues on both devices.

- Howover Landscape mode still failed on HTC Sense, but shown like the picture (GETSCREENSIZE and GETDESKTOPSIZE values is swapped). Here its should set back to portrait mode and set ORIENTATION to value from GetOrientation(). I do believe that bug is property fixed.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Kitty Hello

Use portrait or sensor, only. Both work with the next update. (On my touchpad)

spacefractal

Yep, when SETSCREEN is fixed and dosent swap X/Y like this:


Then all orientation issues can been fixed by this thread (include above device, which is a HTC Desire HD, Not a HTC Sense):
http://www.glbasic.com/forum/index.php?topic=8634.0

As you see, the orientation issue did fixed that by that java command too.

So I thinks its fixed now and Im looking forward to the next beta, and very thanks for the effoct (and I missing the donate button too, hehe).



Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

bigsofty

Maybe related...
Code (glbasic) Select
glGetIntegerv(GL_VIEWPORT, viewPort);

Shows that the screen is for example 720x1280 on Android (Project setting is 1280x720) and on Windows it's 1280x720. On Android X & Y are also stuck in portrait mode, even though GLBasic is on Landscape. So raw OpenGLES is rendering YX for me, while GLB is rendering XY. I had assumed that this was due to some sort of GLB 2D transform but now I am not so sure it looks like a screen rotation issue.

BTW GETSCREENSIZE is reporting 1280x720 on Android, while GL_VIEWPORT is reporting 720x1280.

I may be reporting something that has already been seen to by the sounds of it though. If so, is the next beta available to test?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

spacefractal

Yep its that its happens.

That bug should been fixed now. Glbasic can property still orientation wrong, but that is fixable by your self, so that bug is not 100% important at all.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/