Skip to content
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

iOS landscape orientation is drawn upside down #6317

Closed
liamlacey opened this issue Jun 24, 2019 · 7 comments · Fixed by #6363
Closed

iOS landscape orientation is drawn upside down #6317

liamlacey opened this issue Jun 24, 2019 · 7 comments · Fixed by #6363
Assignees

Comments

@liamlacey
Copy link

When setting the iOS orientation mode to landscape (90_LEFT or 90_RIGHT) the window is drawn upside down (meaning touch position 0,0 is at the bottom right instead of the top left).

I’ve tested this with iosOrientationExample with iOS release version 0.10.1, using an iPhone 8 running the latest iOS version.

@liamlacey
Copy link
Author

I've added a workaround for this by adding the following to my touch functions in order to get the correct touch x and y values:

    if (ofGetOrientation() == OF_ORIENTATION_90_LEFT || ofGetOrientation() == OF_ORIENTATION_90_RIGHT)
    {
        touch.x = ofGetWidth() - touch.x;
        touch.y = ofGetHeight() - touch.y;
    }

However a second issue I've now found is that if I do a double tap it will call touchDoubleTap as expected but then also trigger a touchDown with the correct touch x and y values, which then means by above workaround won't work.

@ofTheo ofTheo self-assigned this Aug 22, 2019
@ofTheo
Copy link
Member

ofTheo commented Aug 22, 2019

Thanks @liamlacey !
Do the graphics also seem flipped or is it just the touch points?

@liamlacey
Copy link
Author

Hi ofTheo,
I seem to remember that the issue is that the whole window/view/graphics is being drawn upside down, but with the touch points being as they should be.

@liamlacey
Copy link
Author

Resulting in the touch points being flipped compared to the view.

@ofTheo
Copy link
Member

ofTheo commented Aug 22, 2019

Thanks @liamlacey - I'll take a look!
Sounds like it should be easy to reproduce :)

@ofTheo
Copy link
Member

ofTheo commented Aug 24, 2019

@liamlacey I was able to reproduce on my end for both device and simulator.

Could you confirm that switching the (CGPoint)orientateTouchPoint:(CGPoint)touchPoint { in

ofxiOS/src/core/ofxiOSEAGLView.mm

to:

        case OF_ORIENTATION_90_RIGHT:
            touchPointOriented.x = touchPoint.y;
            touchPointOriented.y = ofGetHeight() - touchPoint.x;
            break;
            
        case OF_ORIENTATION_90_LEFT:
            touchPointOriented.x = ofGetWidth() - touchPoint.y;
            touchPointOriented.y = touchPoint.x;
            break;

Fixes the issue for you?
It seems to work correctly now for me now.

@ofTheo
Copy link
Member

ofTheo commented Aug 27, 2019

@danoli3

Here is a simple example to reproduce the bug.
I see it with both ofxiOSGLKView.mm and ofxiOSEAGLView.mm when hardware orientation is disabled.

I was going to switch both to as above - but just wanted to get your take first.
I remember OF_ORIENTATION_90_RIGHT/LEFT and the iOS equivalent was always a little tricky.

//--------------------------------------------------------------
void ofApp::setup(){	
	ofSetOrientation(OF_ORIENTATION_90_RIGHT);//Set iOS to Orientation Landscape Right
}

//--------------------------------------------------------------
void ofApp::update(){
}

ofPoint lastTouchPt;
//--------------------------------------------------------------
void ofApp::draw(){
    
    ofSetColor(255, 0, 0);
    ofDrawCircle(ofGetMouseX(), ofGetMouseY(), 30);

    ofSetColor(0, 255, 0);
    ofDrawCircle(lastTouchPt.x, lastTouchPt.y, 30);
	
}

//--------------------------------------------------------------
void ofApp::touchDown(ofTouchEventArgs & touch){
    lastTouchPt = touch;
    
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants