Android Question LibGDX TransparentView vs. BringToFront

wonder

Expert
Licensed User
Longtime User
Bonjour!! :)

Here's the situation, if I have a regular button / label / textbox at (for example) the center on the screen and non-visible LibGDX surface below, the behavior is as follows:
B4X:
Sub myButton_Click
    'Toggle LibGDX visibility on and off
    lGdxSurface.Visible = (lGdxSurface.Visible == False)
    'Display the button on top
    myButton.BringToFront
End Sub

With a non-transparent view lGdxSurface.InitializeView2(Config, "LG")
- No problem, it behaves as expected

With a transparent view lGdxSurface.InitializeTransparentView(Config, "LG")
- The button will stay behind, BringToFront just doesn't work.

Additional notes:
- I tried myButton.BringToFront with CallSubUI as well, no success.
- Initializing in a certain order (libGDX before Button) doesn't work either, plus even if it did, it's not the solution I'm looking for.

Attached, the best solution I could come-up with.
 

Attachments

  • BlurEverythingBelow.zip
    15 KB · Views: 242
Last edited:

Informatix

Expert
Licensed User
Longtime User
You should read the help text of the InitializeTransparentView function:
This function has to be called in Activity_Create. It sets up all the things necessary to get input, render via OpenGL and so on, with the specified configuration. It returns the created view.
The created view is always over the activity contents and may be transparent if glClearColor has alpha < 1.
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
so trying to move it behind is a bit strange
Not at all. :)

Take this picture, for example:

ce069dc38746a30345fd302e8114c89c.jpg


The vase is opaque, the window is transparent and the background is opaque.
If I took a black marker, I could draw a smiley on the window glass.

Imagining the LibGDX transparent view as this window's glass surface, it does make perfect sense to have a transparent view between 2 others (opaque or not).

example1.png
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Not at all. :)

Take this picture, for example:

ce069dc38746a30345fd302e8114c89c.jpg


The vase is opaque, the window is transparent and the background is opaque.
If I took a black marker, I could draw a smiley on the window glass.

Imagining the LibGDX transparent view as this window's glass surface, it does make perfect sense to have a transparent view between 2 others (opaque or not).

example1.png
AFAIK, a surface is always behind or above the window holding the views, so what you want is not possible.
Anyway, why don't you draw everything on the libGDX surface? What views are supposed to be in PanelA and PanelB?
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Oh well, if it's already done, there's no point in perusing this project any further.

Nevertheless, it was a very nice learning experience!
Plus, in the end, I got it working with a non-transparent surface. :)

My algo goes like this:
- Create a screenshot (bitmap) in memory (no saving)
- Bitmap --> Byte() --> Pixmap --> lgTexture
- Apply the Blur shadder and display the LibGDX surface (w/ continuous rendering: OFF)

Thanks for everything!
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Oh well, if it's already done, there's no point in perusing this project any further.

Nevertheless, it was a very nice learning experience!
Plus, in the end, I got it working with a non-transparent surface. :)

My algo goes like this:
- Create a screenshot (bitmap) in memory (no saving)
- Bitmap --> Byte() --> Pixmap --> lgTexture
- Apply the Blur shadder and display the LibGDX surface (w/ continuous rendering: OFF)

Thanks for everything!
Do you agree to share your code? It may be instructive.
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
As promised, I've attached the project to the first post.

With LibGDX opaque view:
- I'm unable to eliminate the "flickering" that sometimes happens during the split-second the transition occurs.
- I'm able to use .BringToFront on the Blur button.

With LibGDX transparent view:
- I'm able to eliminate the "flickering" that sometimes happens during the split-second the transition occurs.
- I'm unable to use .BringToFront on the Blur button.

As a practical solution already exists, I won't be working on this anymore.
Nevertheless, please consider my request of allowing the LibGDX transparent surface to sit between views.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
As promised, I've attached the project to the first post.

With LibGDX opaque view:
- I'm unable to eliminate the "flickering" that sometimes happens during the split-second the transition occurs.
- I'm able to use .BringToFront on the Blur button.

With LibGDX transparent view:
- I'm able to eliminate the "flickering" that sometimes happens during the split-second the transition occurs.
- I'm unable to use .BringToFront on the Blur button.

As a practical solution already exists, I won't be working on this anymore.
Nevertheless, please consider my request of allowing the LibGDX transparent surface to sit between views.
Some files are missing (vertex, fragment, ...).
 
Upvote 0

wonder

Expert
Licensed User
Longtime User
Yeah, mine always blurs, but it flickers sometimes... It is possible that the resize event is being fired before the screenshot is ready...
I'm not experienced with multithreaded apps, I'm almost sure I messed it up...

I guess that, at least as a proof of concept, it kinda works.

If you're into it, you could try fixing it and/or experimenting with the Transparent surface, which doesn't need the trickery of moving the surface up and down from 0%y to 100%y in order to hide/unhide.

By the way, here's the whole thing, apk included:
http://www113.zippyshare.com/v/NoYdXIwK/file.html
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Nevertheless, please consider my request of allowing the LibGDX transparent surface to sit between views.
It's not possible. A surface has only two positions set by the setZOrderOnTop function, either on top or behind, and only the "on top" position allows the surface view to be transparent.

In brief:
With InitializeView, the created view is always opaque. There's no way to see anything through it, whatever you set with GL.glClearColor. SendToBack and BringToFront work as expected.
With InitializeTransparentView, the created view is always transparent, but you can hide what's behind by setting an opaque color with GL.glClearColor (you change the background color of the drawing surface). SendToBack and BringToFront do not work because the surface is always above.
 
Upvote 0
Top