Android Question glSurfaceView and ResumableSubs

mmieher

Active Member
Licensed User
I post this for the common good. I solved the problem with a work-around, but I need to know why the following does not work.

The order in which I call WaitFor subs should not matter? This is a trimmed-down version of a large project.

B4X:
Sub Process_Globals
    Private xui As XUI
End Sub

Sub Globals
    Private GLS1 As glSurfaceView
    Private Facelist As List
    Private mbm(6) As Bitmap
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
   
    '    The following two lines in this order WORK
    Wait For(DisplaySplash) complete (Result As Int)
    Wait For (GetConfigFile) complete (Result As Int)
   
   
    '    The following two lines in this order DOES NOT WORK
    ''Wait For (GetConfigFile) complete (Result As Int)
    ''Wait For(DisplaySplash) complete (Result As Int)
   
End Sub

Private Sub GetConfigFile As ResumableSub
    Log("GetConfigFile")
    Return 0
End Sub

Private Sub DisplaySplash As ResumableSub
    Log("DisplaySplash")
   
    Facelist.Initialize
    'add 6 images to (List) facelist - one for each of the faces of the cube
    mbm(0).Initialize(File.DirAssets,"rcYellow.png")
    Facelist.Add(mbm(0))
    mbm(1).Initialize(File.DirAssets,"rcRed.png")
    Facelist.Add(mbm(1))
    mbm(2).Initialize(File.DirAssets,"rcBlue.png")
    Facelist.Add(mbm(2))
    mbm(3).Initialize(File.DirAssets,"rcGreen.png")
    Facelist.Add(mbm(3))
    mbm(4).Initialize(File.DirAssets,"rcWhite.png")
    Facelist.Add(mbm(4))
    mbm(5).Initialize(File.DirAssets,"rcOrange.png")
    Facelist.Add(mbm(5))
   
    GLS1.Color = Colors.Transparent    '    does not work
    'pass (List) facelist on to the wrapper
    GLS1.SixFaces = Facelist
   
    'this has to be set AFTER the LIST has been passed to the wrapper
    GLS1.ZoomInOut = True                       'it will make the cube zoom In/Out while spinning anround the below defined RotationPlane
    'GLS1.CubeSpeed = 3.0                        'A negative value will reverse the direction of the spin
    GLS1.CubeSpeed = 1.0                        'A negative value will reverse the direction of the spin
    GLS1.RotationPlane(1.0, -1.0, 0.0)          'Keep these values between 0.0 and 1.0 (you can also apply negative values)
   
    Return 0
   
End Sub
 

Attachments

  • GLSVIssue.zip
    123.3 KB · Views: 22

agraham

Expert
Licensed User
The order in which I call WaitFor subs should not matter?
What makes you think that? It can/does matter - or do you mean in this particular instance?.

What does "not work" mean. I suspect what you may be overlooking here is that a Wait For in Activity_Create will immediately return and run Activity_Resume. This can catch you out when getting permissions for example.

Which glSurfaceView library are you using? The one in the link you gave above does not implement SixFaces and some other methods used in your program.
 
Upvote 0

mmieher

Active Member
Licensed User
Thanks, Agraham.

By, "not work" I mean the rotating cube does not appear.

I get the Activity_Create thing. I put "If FirstTime" in Activity_Create. No difference.

Wrong glsurface library? Calling the empty sub GetConfigFile after the Display Splash shows the proper six sides? No error. Library is 1.00. Will ook for another version.

Will dig more.
 
Upvote 0

mmieher

Active Member
Licensed User
FirstTime will no longer be True in Activity_Create after a Wait For. Post the actual glSurfaceView library jar and xml that you are using so I can try it.

This is the only version I can find in the forums.

Thanks.
 

Attachments

  • glSurfaceView.jar
    18.8 KB · Views: 20
  • glSurfaceView.xml
    10.1 KB · Views: 23
Upvote 0

agraham

Expert
Licensed User
That version works with your code. I see the same as you. Any call to Wait For, including a Sleep(0), before invoking DisplaySplash in either Create or Resume causes the cube not to appear.

I am at a loss to explain this. I've looked inside the jar and the library doesn't seem to do anything awful so I think it must be something in OpenGL itself reacting to something the Wait For mechanism does. Possibly it is stopping the OpenGL rendering loop starting, or stopping it if it is going.
 
Upvote 0

mmieher

Active Member
Licensed User
That version works with your code. I see the same as you. Any call to Wait For, including a Sleep(0), before invoking DisplaySplash in either Create or Resume causes the cube not to appear.

I am at a loss to explain this. I've looked inside the jar and the library doesn't seem to do anything awful so I think it must be something in OpenGL itself reacting to something the Wait For mechanism does. Possibly it is stopping the OpenGL rendering loop starting, or stopping it if it is going.
I appreciate your time.
 
Upvote 0
Top