Drawing a display on top of a canvas

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Drawing a display on top of a canvas

Trixt0r
Hey guys,
 
I am working with an OpenGL based framework (LibGdx) and I am drawing all my OpenGL stuff onto a java.awt.Canvas. Now my problem is that I want to draw a Pivot GUI on top of the canvas but the Display hides everything behind it, even if I change the backgroundColor style to “new Color(0,0,0,0)”. Here is a picture to illustrate my problem:
 
and here are the borders of the display: http://imageshack.com/a/img585/6462/eoy9.png
 
Do I have to reimplement the DisplayHost class or is there another way to draw a Pivot GUI above a Canvas.
Btw, the problem is not related to the fact that I am drawing with OpenGL to the canvas. I tested it with another canvas object which was generated with normal Java2D.
 
Some other information:
  • Everything is rendered in a JFrame.
  • The Pivot DisplayHost and the Canvas are inside a JPanel.
I hope you guys can help me. I could not find anything useful on the internet.
 
Thanks for your help!
 
- Trixt0r
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drawing a display on top of a canvas

Roger and Beth Whitcomb
What happens if you set the backgroundColor style to null (in BXML it would be $bxml:null)?

~Roger

On 3/3/14 3:12 PM, Heinrich Reich wrote:
Hey guys,
 
I am working with an OpenGL based framework (LibGdx) and I am drawing all my OpenGL stuff onto a java.awt.Canvas. Now my problem is that I want to draw a Pivot GUI on top of the canvas but the Display hides everything behind it, even if I change the backgroundColor style to “new Color(0,0,0,0)”. Here is a picture to illustrate my problem:
 
and here are the borders of the display: http://imageshack.com/a/img585/6462/eoy9.png
 
Do I have to reimplement the DisplayHost class or is there another way to draw a Pivot GUI above a Canvas.
Btw, the problem is not related to the fact that I am drawing with OpenGL to the canvas. I tested it with another canvas object which was generated with normal Java2D.
 
Some other information:
  • Everything is rendered in a JFrame.
  • The Pivot DisplayHost and the Canvas are inside a JPanel.
I hope you guys can help me. I could not find anything useful on the internet.
 
Thanks for your help!
 
- Trixt0r

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Drawing a display on top of a canvas

Trixt0r
Roger and Beth Whitcomb wrote
What happens if you set the backgroundColor style to null (in BXML it
would be $bxml:null)?

~Roger
Thanks for the reply.
Setting the background color to null makes no difference.
Anyway, I figured out how to draw a Pivot GUI above a java.awt.Canvas.

For anyone who is going to have the same problems:
First of all, you have to override the paint method of ApplicationContext.DisplayHost:
ApplicationContext.DisplayHost displayHost = new ApplicationContext.DisplayHost(){
                        @Override
                public void paint(Graphics g){
                 super.print(g);
                }
        };
So instead of painting the display, you print it.
Then put this displayHost into a JPanel. Set the JPanel's opaque property to false (jpanel.setOpaque(false))
and set the dislplay background transparent (displayHost.getDisplay().getStyles().put("backgroundColor", new Color(0,0,0,0))).

To draw your canvas behind the Pivot GUI you have to create another JPanel and override its paint method:
@Override
public void paint(Graphics g){ yourCanvas.paint(g);}

Then you can add your both JPanels to a JFrame or to another JContainer.

My problem is now, that my canvas, which draws OpenGL stuff, only draws its background and not the actual content. But that is not your problem, so I am going to ask this in the Libgdx forum.

- Trixt0r
Loading...