Create or choose window's size at app launch

#1

Hello,
is there a way to choose (or enter with keyboard) the main window’s size (and other variables) when launching open frameworks app ? with console ?

#2

I haven’t used it yet, but the add-on ofxArgParser is designed to let you get the command line arguments to your program, which you could then pass to ofSetupOpenGL in main.cpp.

Or, you could start with a small window size and program a text entry control in OF to take screen size parameters.

#3

Thanx Drazinut.
I tried with :
string width = ofSystemTextBoxDialog(“Width:”);
string height = ofSystemTextBoxDialog(“Height:”);
if(width.length()) {X=ofToInt(width);}
if(height.length()) {Y=ofToInt(height);}
ofSetWindowShape(X,Y);
It works, but dialog boxes one after another when you have more than 2 variables is a bit long to proceed.

So I ended with a xml file I can edit quickly and change all variable at same time.
i start with a small window size as you told me, and:
XML.loadFile(“myDimensions.xml”);
X = XML.getValue(“WIDTH”, 1280);
Y = XML.getValue(“HEIGHT”, 720);
. …
with my xml file :
< WIDTH >1280
< HEIGHT >720

1 Like
#4

…and of course:
ofSetWindowShape(X,Y);
to set my window with new size.

#5

I’m glad you got it working. Thanks for sharing what you did.