What's the relation between GLCanvas.setsize , JFrame.setsize , JFrame.getLocationOnScreen , and gl.glViewport?

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

What's the relation between GLCanvas.setsize , JFrame.setsize , JFrame.getLocationOnScreen , and gl.glViewport?

HamudHaa
This post was updated on .
Are they referring to the same size beginning at the same left corner coordinate and the same width and height ?
Is glViewport automatically called when the window is resized ?
What should I do to prevent jogl from automatically stretching my screen after resizing? I'd like to have it to show part of my screen or blackness which is not rendered when I'm resizing and moving the window .
And , if I have blackness outside the rendered area after resizing the window , what should I do to stretch the screen to fit the blackness ? This is the problem I'm facing when messing around offscreen rendering where I'm trying to set glViewport larger than the GLcanvas ( which is also the size of JFrame ). In my case the output image fills the exceeded area with blackness while my stuff are placed at a corner . But , isn't glViewport remapping NDC to framebuffer ? How could you even be possible to render only part of the viewport ?  My explanation is that , since I'm calling glviewport in init . There might be another glviewport is called from another place which overrode my call of glviewport .
Thanks all your replies
Reply | Threaded
Open this post in threaded view
|

Re: What's the relation between GLCanvas.setsize , JFrame.setsize , JFrame.getLocationOnScreen , and gl.glViewport?

gouessej
Administrator
Hello

Don't make a confusion between the size of the canvas/frame/window (it becomes even more complicated with HiDPI) and the size of the viewport, these are distinct concepts.

Moreover, OpenGL and Swing/AWT can have distinct point of references.

You can implement this method to set the viewport when the canvas has just been resized:
https://jogamp.org/deployment/jogamp-next/javadoc/jogl/javadoc/com/jogamp/opengl/GLEventListener.html#reshape(com.jogamp.opengl.GLAutoDrawable,int,int,int,int)
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: What's the relation between GLCanvas.setsize , JFrame.setsize , JFrame.getLocationOnScreen , and gl.glViewport?

HamudHaa
Hi . Yes , after testing my codes , I found that before display is called and after init is over , there's a call to reshape which will automatically set glviewport to the size of the window . Yes , they're independent things .
Another question : When I'm using glviewport , as well as printing a and b value received in reshape method , why the x,y coordinates are always 0 ? Won't the left bottom corner change when I'm moving the window ?