Overlay is stretched when viewport is not covering the full windows

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

Overlay is stretched when viewport is not covering the full windows

Martin
Hi all,
What I describe here is a problem I found on jogl1 as well.

In jzy3d, the scene rendering is handled by a View that is able to either stretch on the full windows, or remain square on the screen by using the minimum between width and height. In the second case, the overlay is rendered stretched.

You can look the following 3 images two understand the problem: first picture [1] shows a chart in a square window, with the red grid showing that the viewport occupies the complete window surface. The overlay renders properly a black rectangle in the upper left corner.


Second picture [2] shows the result of resizing the window and rendering on the complete window area... in other word:
gl.glViewport(0, 0, width, height);
the overlay still renders as expected.


The third picture [3] shows the result of resizing the window and rendering on sub part of the window area... in other word we may have something like:
gl.glViewport(100, 0, width-200, height);
The overlay renders all java2d instructions stretched.


My code simply does:

gl.glViewport(viewport.x, viewport.y, viewport.width, viewport.height);
               
if(overlay!=null && viewport.width>0 && viewport.height>0){
  Graphics2D g2d = overlay.createGraphics();    
        g2d.setBackground(bgOverlay);
  g2d.clearRect(0, 0, canvas.getRendererWidth(), canvas.getRendererHeight());
     
  for(ITooltipRenderer t: tooltips)
    t.render(g2d);      
  for (Renderer2d renderer : renderers)
      renderer.paint(g2d);
     
  overlay.markDirty(0, 0, canvas.getRendererWidth(), canvas.getRendererHeight());
  overlay.drawAll();
  g2d.dispose();
}


Is that a normal behavior for the overlay? I spent lot of time trying to forbig such stretching without finding how to do that. I would also be pleased to know how to force the overlay to appear at a desired position instead of top-left corner.

Regards,
Martin

[1] http://jzy3d.free.fr/overlay/overlay-standard.png
[2] http://jzy3d.free.fr/overlay/overlay-nobug.png
[3] http://jzy3d.free.fr/overlay/overlay-bug.png
Reply | Threaded
Open this post in threaded view
|

Re: Overlay is stretched when viewport is not covering the full windows

Wade Walker
Administrator
Have you tried this?

overlay.beginRendering();
overlay.draw(int screenx, int screeny, int overlayx, int overlayy, int width, int height );
overlay.endRendering();

Supposedly it allows you to draw the overlay starting at a given screen location, and to draw a sub-section of the overlay there.

What behavior do you want to happen? Perhaps you could just use the draw call above instead of setting gl.glViewport()?
Reply | Threaded
Open this post in threaded view
|

Re: Overlay is stretched when viewport is not covering the full windows

Martin
Great idea, don't understand why I did not try this before?!
I have to keep the glViewport call because in the context of jzy3d's overlay rendering, the previously applied Viewport is the colorbar one, which is on the right of the scene instead of on top of it.
Many thanks for your suggestion.
Regards,
Martin