Results 1 to 6 of 6

Thread: Rendering issues with iOS orientation

  1. #1
    Squire tehJP's Avatar
    Join Date
    Aug 2012
    Location
    Bristol, UK
    Posts
    14

    Default Rendering issues with iOS orientation

    Running in the iPhone 4.3 simulator it starts in portrait but my irrlicht code is rendering as if it's landscape, whilst the proton hi stuff renders as it should.

    My game only renders in a landscape fashion, is there a way to make proton render my stuff correctly instead of at effectively 90 degrees to how it renders on windows?

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,377

    Default

    It is a little strange that Proton use Portrait mode for Landscape rendering (only on iOS), this is done for legacy reasons (It is 25% faster on older iOS devices) - it does send UI tips so keyboard/notifications pop up landscape though, so to the user there is generally no difference.

    I probably should remove it or at least add a setting to disable this mode to make porting GL code easier.

    For now, to add screen rotation support to existing GL code, you need to add this anywhere you recreate/setup the projection matrix:

    RotateGLIfNeeded(); (for example, a single one of those is used in Irrlicht\source\Irrlicht\COGLESDriver.cpp, and that was all it took for all of Irrlicht to work right with it)

    That will handle it. You may also need to use GetPrimaryGLX() and GetPrimaryGLY() to get that actual portrait sizes for certain low level gl code, instead of using GetScreenSizeX() etc which return the landscape size.

    Also, if you setup the emulation profile to "iPhone" instead of "iPhone Landscape", it will perfectly emulate the rotation stuff under MSVC, so it's easier to debug. (You can also use Ctrl-U to flip the screen upside down along with other hotkeys.

    Edit: You can use Option-Right arrow to flip the emulator screen so it looks right btw, yeah it's annoying.
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Squire tehJP's Avatar
    Join Date
    Aug 2012
    Location
    Bristol, UK
    Posts
    14

    Default

    I'm not doing any GL coding myself, I'm just using Irrlicht to draw a load of 2D stuff and that's what's being rendered at the wrong orientation.

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,377

    Default

    Quote Originally Posted by tehJP View Post
    I'm not doing any GL coding myself, I'm just using Irrlicht to draw a load of 2D stuff and that's what's being rendered at the wrong orientation.
    Hmm, I think I missed a spot in Irrlicht where I need to add the rotation.

    In void COGLES1Driver::setRenderStates2DMode, add RotateGLIfNeeded();

    right after:


    Code:
    	glMatrixMode(GL_PROJECTION);
    
    			const core::dimension2d<u32>& renderTargetSize = getCurrentRenderTargetSize();
    			core::matrix4 m;
    			m.buildProjectionMatrixOrthoLH(f32(renderTargetSize.Width), f32(-(s32)(renderTargetSize.Height)), -1.0, 1.0);
    			m.setTranslation(core::vector3df(-1,1,0));
    			glLoadMatrixf(m.pointer());

    Unfortunately I don't have a on-hand test case to see if this is right, my tank game uses the GUI a bit but renders it in 3d (over the tank meshes) so it doesn't use the 2d blit stuff the same way.
    Seth A. Robinson
    Robinson Technologies

  5. #5
    Squire tehJP's Avatar
    Join Date
    Aug 2012
    Location
    Bristol, UK
    Posts
    14

    Default

    Hopefully that'll work, will try it out this evening!

  6. #6
    Squire tehJP's Avatar
    Join Date
    Aug 2012
    Location
    Bristol, UK
    Posts
    14

    Default

    Yep, managed to get it working. The stock RotateGLIfNeeded() didn't work quite right, needed some tweaking for 2D space:

    Code:
    void RotateGL2DIfNeeded()
    {
        if( GetbaseApp()->GetManualRotationMode() )
        {
            float degrees = -OrientationToDegrees( GetOrientation() ); // note the negation on the function call
            glRotatef( degrees, 0.0f, 0.0f, 1.0f );
        
            if( g_extraScreenRotation != 0 )
            {
                glRotatef( g_extraScreenRotation, 0.0f, 0.0f, 1.0f ); // untested, not sure what this is used for, also negated from stock version
            }
    
            glTranslatef( 0.0f, -320.0f, 0.0f ); // the rotation takes it offscreen and this brings it back on so the origin is in the right place
        }
    }
    Whoops, just noticed I'm not using the actual dimension of the screen for the translation!
    Last edited by tehJP; 08-14-2012 at 08:09 AM.

Similar Threads

  1. image rendering and app rotation issues
    By caboose89 in forum Proton SDK
    Replies: 7
    Last Post: 05-22-2012, 02:45 PM
  2. BlackBerry Orientation
    By JonyMnemonic in forum Proton SDK
    Replies: 2
    Last Post: 02-08-2012, 12:19 AM
  3. Handling orientation change (android)
    By karelc in forum Proton SDK
    Replies: 3
    Last Post: 01-02-2012, 01:37 AM
  4. Rendering to texture
    By Noro in forum Official ClanLib SDK Forums
    Replies: 13
    Last Post: 08-22-2011, 10:28 AM
  5. GUI / Rendering Display
    By Fr3DBr in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 08-22-2009, 11:00 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •