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 3276934
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:18:51+00:00 2026-05-17T19:18:51+00:00

I’m working on an iphone project where I need both a horizontal and a

  • 0

I’m working on an iphone project where I need both a horizontal and a vertical layout. I’ve got it working in 2D perfectly well, using the following setup to my projection matrix:

 if(isHoriz()){
  glRotatef(90.0f,0.0f,0.0f,1.0f);
  SOrtho(0,  480, 0, 320, -1, 1); 
  }
  else
    SOrtho(0,  320, 0, 480, -1, 1); 

The problem lies when I move to 3D

  glViewport(0,0,320,480);   
  glScissor(0,0,320,480); 
  gluPerspective(28.8f,320/480,0.1f,1000.0f);
  if(isHoriz())
    glRotatef(90.0f,0.0f,0.0f,1.0f);

This seems to work, but the view is offset vertically wrong. What I want to happen is that the top half of the vertical display becomes the center of the horizontal display. Instead, it seems like the middle of the vertical display becomes the center of the horizontal display.

Because this is an iphone, the window height (480) and width (320) remain constant regardless of rotation. I’ve tried building the same code into a windows program, and the code that gets the effect I want for the horizontal rotation is simple. I just change the window shape, so that I have a landscape window, and then remove the call to

  if(isHoriz())
    glRotatef(90.0f,0.0f,0.0f,1.0f);

(I also do something similar to the 2D code).

Am I doing something wrong? Why don’t the windows version and the iphone version look the same?

Edit: To clarify, I’ve tried adding glTranslatef() calls above and below the glRotatef call, but this seems to have an effect on the angle of my camera. The camera code is applied to my modelView matrix immediately after the above code. It looks like this:

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(mRotate.mZ,0,0,1);
glRotatef(mRotate.mY,0,1,0);
glRotatef(mRotate.mX,1,0,0);
glTranslatef(-mPos.mX,-mPos.mY,-mPos.mZ);

The initial values of the camera are mRotate.mX = -80, mPos.Z = -8.

  • 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-17T19:18:52+00:00Added an answer on May 17, 2026 at 7:18 pm

    I’m still not certain why this happened, but I moved my rotation from the projection to the modelview and everything works fine. I think it had to do with the fact that the Windows window had a varying shape (either 320×480 or 480×320) that did not match the iPhone shape (always 320×480).

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.