Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6620039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:02:54+00:00 2026-05-25T21:02:54+00:00

Ok, so I have a weird problem with OpenGL in landscape mode on iOS.

  • 0

Ok, so I have a weird problem with OpenGL in landscape mode on iOS.
From what I’ve read on the internet I have to rotate the scene myself, so I did that like this:

void GameViewController::onSurfaceChanged(int width, int height)
{
float aspect = (float)width / (float)height;
float fovy = 90.0f;

glMatrixMode(GL_PROJECTION);

float xmin, xmax, ymin, ymax;
ymax = 0.01f * Math::tan(fovy * 3.1415f / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;

glViewport(0, 0, width, height);

glLoadIdentity();
glRotatef(-90.0f, 0.0f, 0.0f, 1.0f);
glFrustumf(xmin, xmax, ymin, ymax, 0.01f, 320.0f);
}

My center of my camera isn’t the center of the screen now though. So I reset all matrices (projection, modelview) so they are all identity, and then I drew a unit circle on the screen. Now I see what’s going wrong, not all coordinates from -1 to 1 are actually on my screen! Here is a screenshot to show what I mean:
circle that should be in the center of the screen

Now my question: what could possibly cause this?

EDIT: after some more investigation i found that in this obj-c method:

-(void)setupView:(GLView*)view
{
CGRect rect = view.bounds; 
glViewport(0, 0, rect.size.width, rect.size.height);  

gameView->onSurfaceCreated();
gameView->onSurfaceChanged(rect.size.width, rect.size.height);

view.multipleTouchEnabled = YES;
}

the view’s size suddenly turned out to be 1216*1568. The problem is probably there. Manually passing 768 * 1024 to onSurfaceChanged gives me even weirder results.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:02:55+00:00Added an answer on May 25, 2026 at 9:02 pm

    Seems like there was an error in the template I was using. Using the default Open GL ES template way of creating a context gives me the proper 1024*768 screen size. Problem fixed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird problem that i can't figure out a solution for: I've
Hey guys, I have a weird problem. I have an update system that refreshes
We have a weird intermittent problem with saving from Word 2007 to our SharePoint
I have a weird problem. I develop my sites on localhost and after that
I have a weird problem building a release of an erlang application that I'm
I have a weird problem that sometimes when I make a change to a
I have a weird problem with routing. I have an existing website that I
I have a weird problem on my hand. I am trying to read an
I have a weird problem with Magento cache. I have an extension that have
I have a weird problem with doctype, the weird thing is that the website

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.