We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › OpenGL canvas does not resize when embeded
Page Index Toggle Pages: 1
OpenGL canvas does not resize when embeded (Read 1255 times)
OpenGL canvas does not resize when embeded
Nov 25th, 2008, 5:07pm
 
I embeded the Synchronised Threads demo from http://www.shiffman.net/teaching/a2z/threads/#thread into a Java AWT Frame. I'd like to be able to resize the canvas with OpenGL whenever the parent frame is resized. However, the size of the canvas stays the same, just the position of the camera changes. I've read in the code for the SimpleGLCanvas demo that comes with the NetBeans OpenGL plug-in (https://netbeans-opengl-pack.dev.java.net/) that it's a known problem, which is solved by calling

setMinimumSize(new Dimension());

on a newly-created GLCanvas object.

Has somebody ever looked at this problem? Can it be fixed?

Many thanks in advance

FYI: my demo is running on Linux and can be compiled both in NetBeans and with a Makefile


Re: OpenGL canvas does not resize when embeded
Reply #1 - Dec 4th, 2008, 5:35pm
 
This problem has gone as soon as I moved from Java1.5 to Java1.6
Re: OpenGL canvas does not resize when embeded
Reply #2 - Dec 4th, 2008, 6:29pm
 
I have this problem too.  Does anyone know what's going on, or have some workaround with Java 5?  I want to distribute to clients with OSX PPC, which does not support Java 6.
Re: OpenGL canvas does not resize when embeded
Reply #3 - Dec 4th, 2008, 10:30pm
 
i have a problem which seems somehow similar.

if make the window resizable, the openGL canvas remain at the original window size when resizing the window. however this work ok when using Java2D or java3D rendering engine.

i'm on windows with java 1.6. any ideas how to fix this ?

Re: OpenGL canvas does not resize when embeded
Reply #4 - Jan 3rd, 2009, 10:24am
 
Hi, I had a similar issue. I resolved it by making a call to glViewport whenever the frame is resized, like so:

Code:
pgl = (PGraphicsOpenGL) g;
gl = pgl.beginGL();
gl.glViewport(0, 0, width, height);
pgl.endGL();


hth, Angus
Re: OpenGL canvas does not resize when embeded
Reply #5 - Jan 3rd, 2009, 10:57am
 
yeah thanks !
it works. you made my day.

Re: OpenGL canvas does not resize when embeded
Reply #6 - Jan 3rd, 2009, 5:24pm
 
Wow, it works.  A million thanks, spiraljetty!

The display does get cut-off when resize expands beyond the original dimensions.  For now, I just set some arbitrarily large dimensions, but I wonder if there is a more elegant way around this.
Page Index Toggle Pages: 1