Hello i want to use the display in vertical but dont want to set “monitor rotation in OS”
I know i can use, to set window orientation, but problem is that im using a gui and mouse coords must not adapt to the orientation and is not possible to use it
https://openframeworks.cc/documentation/application/ofAppBaseWindow/#show_setOrientation
Is there any way to solve this?
Thanks
which OS are you developing for?
you expect mouse coordinates are rotated too? like swapping x and y?
I think so, as i cant use the gui, dont respond to mouse and I suspect is for the swapped axis
there is a function called rotateMouseXY which does this case by case, it is not applied by default.
I’m working on a idea of having a matrix to multiply and translate rotation and scale (in the case of high density screens) to translate mouse coordinates, something like this
// seems to work with -90, 90, 180
float angle = glm::radians(180.0);
glm::mat4 t1 = glm::translate(glm::mat4(1.0), glm::vec3(-ofGetHeight() * .5, -ofGetWidth() * .5, 0));
glm::mat4 r1 = glm::rotate(glm::mat4(1.0), angle, glm::vec3(0.f, 0.f, 1.f));
glm::mat4 t2 = glm::translate(glm::mat4(1.0), glm::vec3(ofGetWidth() * .5, ofGetHeight() * .5, 0));
// glm::mat4 s1 = glm::scale(glm::mat4(), glm::vec3(2.0, 2.0, 0.0));
glm::mat4 model = t2 * r1 * t1;
glm::vec4 mouse2 = model * glm::vec4{ mouseX, mouseY, 1, 1 } ;
ofSetColor(0, 255, 0);
ofDrawCircle(mouseX, mouseY, 30);
ofSetColor(255,0,30);
ofDrawCircle(mouse2.x, mouse2.y, 30);
ofDrawLine(mouseX, mouseY, mouse2.x, mouse2.y);
I didnt know about that function, however seems to be implemented
int modifiers = glfwtToOFModifiers(mods);
ofMouseEventArgs args(action, instance->events().getMouseX(), instance->events().getMouseY(), button, modifiers);
instance->events().notifyMouseEvent(args);
}
//------------------------------------------------------------
void ofAppGLFWWindow::motion_cb(GLFWwindow* windowP_, double x, double y) {
ofAppGLFWWindow * instance = setCurrent(windowP_);
rotateMouseXY(instance->orientation, instance->getWidth(), instance->getHeight(), x, y);
ofMouseEventArgs::Type action;
if(!instance->buttonPressed){
action = ofMouseEventArgs::Moved;
}else{
action = ofMouseEventArgs::Dragged;
}
ofMouseEventArgs args(action,
x*instance->pixelScreenCoordScale,
I checked and that function is called… however at least in my case i have to swap the values of 90_RIGHT to 90_LEFT and reverse… dont know if is the expected behaviour or i should post an issue with a pr…
@arturo should i post a pr?
static void rotateMouseXY(ofOrientation orientation, int w, int h, double &x, double &y) {
int savedY;
switch(orientation) {
case OF_ORIENTATION_180:
x = w - x;
y = h - y;
break;
case OF_ORIENTATION_90_LEFT:
savedY = y;
y = x;
x = w-savedY;
break;
case OF_ORIENTATION_90_RIGHT:
savedY = y;
y = h - x;
x = savedY;
break;
case OF_ORIENTATION_DEFAULT:
default:
break;
}
}
Hey, there are deeper issues with orientation right now and things will change in this code when they are correctly handled. my suggestion is you use your transformation for now, using matrixes or code from rotateMouseXY
related:
opened 03:08AM - 07 May 22 UTC
There is some issues related to iOS orientation, physical vs. screen
I've seen … in different issues, some I've experienced and now begining to understand better.
There is the fact that if you want to keep the content in the upright position, when screen is rotated physically to the left, you want to rotate content to the right.
- https://github.com/openframeworks/openFrameworks/issues/6053
other confusions arise from the lack of separation between physical orientation and screen orientation.
so some functions are not very clear, like ofGetOrientation
- https://github.com/openframeworks/openFrameworks/issues/5612
- https://github.com/openframeworks/openFrameworks/issues/4508
And finally the fact the auto rotation is broken (I've opened this issue in 2018). I can fix this one with a PR
- https://github.com/openframeworks/openFrameworks/issues/6076
I think this can be fixed with one PR in ofAppiOSWindow.mm (line 232 - 235)
Maybe another in ofAppGLFWWindow if needed (returning { x, y } or { y, x } when rotated)
And maybe better documentation, example or even a function to get physical orientation.
Other related issues:
- https://github.com/openframeworks/openFrameworks/issues/4154
- https://github.com/openframeworks/openFrameworks/issues/3130
- https://github.com/openframeworks/openFrameworks/issues/6723
opened 03:08AM - 07 May 22 UTC
There is some issues related to iOS orientation, physical vs. screen
I've seen … in different issues, some I've experienced and now begining to understand better.
There is the fact that if you want to keep the content in the upright position, when screen is rotated physically to the left, you want to rotate content to the right.
- https://github.com/openframeworks/openFrameworks/issues/6053
other confusions arise from the lack of separation between physical orientation and screen orientation.
so some functions are not very clear, like ofGetOrientation
- https://github.com/openframeworks/openFrameworks/issues/5612
- https://github.com/openframeworks/openFrameworks/issues/4508
And finally the fact the auto rotation is broken (I've opened this issue in 2018). I can fix this one with a PR
- https://github.com/openframeworks/openFrameworks/issues/6076
I think this can be fixed with one PR in ofAppiOSWindow.mm (line 232 - 235)
Maybe another in ofAppGLFWWindow if needed (returning { x, y } or { y, x } when rotated)
And maybe better documentation, example or even a function to get physical orientation.
Other related issues:
- https://github.com/openframeworks/openFrameworks/issues/4154
- https://github.com/openframeworks/openFrameworks/issues/3130
- https://github.com/openframeworks/openFrameworks/issues/6723
Yep i saw those but think was related to ios, anyway for me is solved changing that lines in the function you told me, thanks!!
1 Like