Android Question Crash Using glSurfaceView Library

mmieher

Active Member
Licensed User
Longtime User
Reference this post: https://www.b4x.com/android/forum/threads/3d-spinning-cube.92442/#content

The demo B4A app runs fine. Would love this to work. When I try to do the same thing in another app, it spins for a few seconds then crashes with:

java.lang.IllegalArgumentException: bitmap is recycled
at android.opengl.GLUtils.texImage2D(GLUtils.java:152)
at com.test.PhotoCube.loadTexture(PhotoCube.java:143)
at com.test.MyGLRendererPhoto.onSurfaceCreated(MyGLRendererPhoto.java:37)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1539)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)

My code:
B4X:
    Private GLS1 As glSurfaceView
    Dim Facelist As List
    Dim mbm(6) As Bitmap

Private Sub DisplaySplash As ResumableSub
        
    SplashPage.Initialize("SplashPage")
    Root.AddView(SplashPage,0,0,100%x,100%y)
    SplashPage.LoadLayout("Splash")
    
    Facelist.Initialize
    'add 6 images to (List) facelist - one for each of the faces of the cube
    mbm(0).Initialize(File.DirAssets,"RC_image1.png")
    Facelist.Add(mbm(0))
    mbm(1).Initialize(File.DirAssets,"RC_image2.png")
    Facelist.Add(mbm(1))
    mbm(2).Initialize(File.DirAssets,"RC_image3.png")
    Facelist.Add(mbm(2))
    mbm(3).Initialize(File.DirAssets,"RC_image4.png")
    Facelist.Add(mbm(3))
    mbm(4).Initialize(File.DirAssets,"RC_image5.png")
    Facelist.Add(mbm(4))
    mbm(5).Initialize(File.DirAssets,"RC_image6.png")
    Facelist.Add(mbm(5))
    
    '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.RotationPlane(1.0, -1.0, 0.0)          'Keep these values between 0.0 and 1.0 (you can also apply negative values)
   
      SplashTimer.Initialize("SplashTimer",2500)
    ''''  comment out do I can see it for awhile       SplashTimer.Enabled = True
    
    lbPicaCentro.SetVisibleAnimated(3000,True)
    Sleep(3000)
    
    Return 0
    
End Sub
 

mmieher

Active Member
Licensed User
Longtime User
If I load the glsv layout in Activity_Create it works just fine, so I must have been doing something else wrong. Can't seem to change the background color but I'll start a new thread!
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
If I load the glsv layout in Activity_Create it works just fine, so I must have been doing something else wrong. Can't seem to change the background color but I'll start a new thread!
Go here

 
Upvote 0
Top