You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Heinrich Reich <tr...@web.de> on 2014/03/04 00:12:22 UTC

Drawing a display on top of a canvas

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:

how it looks: http://imageshack.com/a/img703/6864/p8ar.png
how it should look: http://imageshack.com/a/img18/2623/7kbk.png
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:
  a.. Everything is rendered in a JFrame. 
  b.. 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

Re: Drawing a display on top of a canvas

Posted by Trixt0r <tr...@web.de>.
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




--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Drawing-a-display-on-top-of-a-canvas-tp4022892p4022894.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Drawing a display on top of a canvas

Posted by Roger and Beth Whitcomb <Ro...@rbwhitcomb.com>.
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:
> how it looks: http://imageshack.com/a/img703/6864/p8ar.png
> how it should look: http://imageshack.com/a/img18/2623/7kbk.png
> 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