-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed windowing/windowExample #8210
base: master
Are you sure you want to change the base?
Conversation
Window position (posx, posy) is now global, rather than being initialized inside ofApp::update (which led to a bug)
Window position (posx, posy) is now global, rather than being initialized inside ofApp::update (which led to a bug)
ballPositionX += ballVelocityX; | ||
ballPositionY += ballVelocityY; | ||
|
||
int posx = ofGetWindowPositionX(); | ||
int posy = ofGetWindowPositionY(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this point to a bug/regression with ofGetWindowPositionX / ofGetWindowPositionY ?
This code used to work.
I appreciate the bug fix for the example, but I think the bigger fix might be to understand why ofGetWindowPosition is not working anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the consideration!
If the code used to work, I agree! I can definitely dive into ofGetWindowPosition in order to understand the issue at a deeper level.
Is it ok to share the insights on this matter in this conversation? If you prefer, we close the PR and we open a new one when I find something interesting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, the following code is already an issue. Even if it looks like the window is beeing set at exactly the same position it already has, in reality the window keeps moving. Precisely, each time it's set at +6 units in x and +27 units in y, with respect to the current position.
void ofApp::update(){
int posx = ofGetWindowPositionX();
int posy = ofGetWindowPositionY();
ofSetWindowPosition(posx, posy);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which platform are you in? it seems the dimensions of window decoration, status bar and border
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working inside WSL -Windows Subsystem for Linux- with Windows 11 and Debian.
The behaviour was not the expected one.
The bounce of the ball on any of the 4 walls always led to an update of the window position towards positive y, making the window to steadily move towards the lower end of the screen.
This was due to the initialization of the variables describing the window position inside ofApp::update().
Now, the variables are initialized in ofApp.h and they're just updated into ofApp::update().
The behaviour is now as expected.