Get screen size?

I have been searching and I can’t find a simple answer to a simple question:

I want to know the screen width and height before creating a window.

What functions will provide this information?

hjh

does this help?

ofGetScreenWidth();
ofGetScreenHeight();
1 Like

As @danb suggested, this is one way of getting this info.
And there is also just:

ofGetWidth();
ofGetHeight();

But just in case if you mean getting the size of your current monitor screen, you might have to use a little workaround:
First, make the window fullscreen, get the window size and revert back like this:

ofSetFullscreen(true); // adjust to fullscreen
int window_Width = ofGetWindowWidth();
int window_Height = ofGetWindowHeight();
ofSetFullscreen(false); // revert back

and then you can use the values stored as window_Width, window_Height…

2 Likes

Hm… in the bindings for Pure Data that I’m using, these functions seem not to exist. (Crash.)

These get the window’s height and width, not the screen’s (… “if you mean getting the size of your current monitor screen”… right, I said “screen” not “window” in my question – this was intentional). Also the fullscreen workaround didn’t work (I still get 500x500).

of-screen-size-nope

hjh

Not tested, but did you tried with getScreenSize() ?
See https://openframeworks.cc/documentation/ -> application section

HTH

Doesn’t exist in these Lua bindings. I may have to ask the author.

hjh

Oh, wait… @danb’s ofGetScreenWidth() and ofGetScreenHeight() do work, but a window must exist first. No window, no numbers.

of-dimensions-ok

OK, solved.

hjh

1 Like

@jamshark70 interesting to know - did it solve what you were trying to figure out?