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 & HelpOpenGL and 3D Libraries › opengl variable screen size
Page Index Toggle Pages: 1
opengl variable screen size (Read 775 times)
opengl variable screen size
May 8th, 2006, 6:52pm
 
Hi,

Just wondering if anyone knows of a way to feed an opengl web applet information from the webpage that contains it (do-able using param), and for the applet to use that information to specify its size?

I came acropper on this before (see http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Contribution_3DOpenGL;action=display;num=1143200497). Is there anyway to get size to use variables?  I've been playing with scary JAVA commands (which I have little experience with) and I've had no joy so far.

Thanks for any suggestions, Andy.
Re: opengl variable screen size
Reply #1 - May 8th, 2006, 8:37pm
 
see: param()

this let's you read the values from the params as specified in the applet tag. the reference page seems to have a problem with not encoded < and > so here's what it should read there:
Code:

// Read the value "51" from the following text embedded in an HTML page:
// <applet code="param_" archive="param_.jar" width=100 height=100>
// <param name="back" VALUE="51">  
// </applet>

String bs= param("back");
int bi = Integer.parseInt(bs);
background(bi);


but:
i don't see why you would want to set the size() via additional params, since it's anyway already set in the tag. just change the applet-tag to change size and use width and height to read it.

?

best,
F
Re: opengl variable screen size
Reply #2 - May 9th, 2006, 6:13pm
 
You can get the actual width and height of the applet by using java.applet.Applet's getWidth() and getHeight().  You can even dynamically keep track of when the size changes (using ComponentListener, I believe, don't remember exactly), and call size() accordingly.  That's useful if you have your applet size set to a variable unit (like 100%).

Marcello
Re: opengl variable screen size
Reply #3 - May 9th, 2006, 6:22pm
 
all that getWidth() and componentlistener stuff is handled internally by PApplet. if you can convince your browser to resize the applet using javascript, then the PApplet will resize itself appropriately.

the result across different browsers is extremely inconsistent, however, so it's not really recommended as something to count on working properly on others' machines.
Re: opengl variable screen size
Reply #4 - May 9th, 2006, 8:31pm
 
It is?  ::goes off to try it out::

awesome!

Now you just need a way to make processing have a resizable window when you hit 'run' to make testing easier...

Anyway, if anyone wants to try:
http://www.cs.unm.edu/~cello/processing/sizetest/

It doesn't use javascript to size or anything.

Marcello
Page Index Toggle Pages: 1