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 & HelpSyntax Questions › Export Application Questions
Page Index Toggle Pages: 1
Export Application Questions (Read 1872 times)
Export Application Questions
Dec 2nd, 2005, 5:38pm
 
I got present mode to work (thanks to the FAQ) by putting this in my sketch...
Code:

static public void main(String args[]) {
PApplet.main(new String[] { "--display=1", "--present", "projectName" });
}


1) Is there a way to make the "projectName" dynamic?  Since I have been doing a bit of testing of the application export feature, I find if the project name parameter doesnt match exactly, the application wont run.  Nothing big... just curious if there was a step saver there.

2) Not sure if this is possible... How can I make a sketch that is, for example, 800x600 run fullscreen but scale up to fill the entire monitor (without having to set the monitor resolution first)?
Re: Export Application Questions
Reply #1 - Dec 3rd, 2005, 6:39pm
 
re #1 unfortunately no.. since the main() is "static", meaning that the code has no sense of what class instance it is, meaning that you can't use getClass().getName() or that sort of thing. if someone else knows a way around this, that'd be great (even perhaps if a class can find out what .jar file it comes from via the classloader, the name could be extracted). perhaps i'll just have to hurry up and get the dialog box for setting export prefs in there.

re #2.. it could be hacked, though you'd also have to remap mouse coords.. unfortunately i think the solution would vary based on the renderer you were using, so it'd probably be easier to add a way to set the display resolution as the thing is started up. someone posted code elsewhere that'll handle that part of it, and i'll probably need to add something like it to the main() as an option as well.
Re: Export Application Questions
Reply #2 - Mar 15th, 2007, 3:32am
 
1) the code is "<your class name>.class.getCanonicalName()" or as used:
Code:

public static void main(String args[]) {
PApplet.main(new String[] { "--display=1", "--present", ThreeDtest.class.getCanonicalName() });
}


the "ThreeDtest" part is the name of the class file (usually the name of the project). I was in the middle of testing some P3D/OpenGL stuff, so you should be able to see where I got my class name from. Bear in mind that I use Eclipse and not PDE, so I'm not sure what modifications might need to be made (hopefully none).
Re: Export Application Questions
Reply #3 - Feb 5th, 2008, 8:53am
 
Hi Everybody,
i assume that flight404 uses the Processing-IDE by saying "putting this in my sketch", and that he exportet the sketch as application. Is that right?
So did i, putting this:

static public void main(String args[]) {
 PApplet.main(new String[] { "--display=1", "--present", "projectName" });
}
in my sketch, exporting to application.
But the application doesn't start at all.
The sketch does, but not in present mode.
Perhaps it's a version issue. I'm using 0134 with Java 1.4.2

I'm searching for a way to build a .exe with fullscreen-mode
Re: Export Application Questions
Reply #4 - Feb 5th, 2008, 9:23am
 
Not very elegant but I got this to work no problems:

Code:

import processing.opengl.*;

static public void main(String args[]) {
PApplet.main(new String[] {
"--display=1", "--present", new CurrentClassGetter().getClassName() }
);
}

void setup(){
size(800,600,OPENGL);
}

void draw(){
}

public static class CurrentClassGetter extends SecurityManager {
public String getClassName() {
return getClassContext()[1].getName();
}
}



I believe you can also create a Throwable to get a classContext without using the SecurityManager object. It's slightly messier.




RE:
Quote:
So did i, putting this:

static public void main(String args[]) {
 PApplet.main(new String[] { "--display=1", "--present", "projectName" });
}  


You must replace "projectName" with your actual project name, which is what we're seeking to modify here.
Re: Export Application Questions
Reply #5 - Feb 6th, 2008, 1:44pm
 
Thanks a lot.
Did not know that the projectname has to match the Main-Sketch name.
Page Index Toggle Pages: 1