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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:09:33+00:00 2026-05-24T10:09:33+00:00

I’m quite new to openGL and I have been trying out some sample codes

  • 0

I’m quite new to openGL and I have been trying out some sample codes from a book about game programming on the iphone that I’m currently reading.
One of the samples was a 3d game and I am able to successfully compile and run it on the iOS simulator (fullscreen).

The problem I have is when I run it on the actual hardware (an ipod touch 4G), the game does not go full screen (it only occupies like 1/4 of the screen). I was able to narrow the problem down to the code below:

GLint backingWidth, backingHeight;

- (BOOL) bindLayer
{
....

glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);

glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);

....
}

For some reason, backingWidth and backingHeight is set to 640 and 960 respectively after the calls above (I expected it to be 320 x 480 which is the iphone’s screen size). On the iOS simulator and an older ipod touch (2g), it works just fine.

The code above is part of an object which subclasses UIView, and overrides the drawRect method (it is empty though). The thing that baffled me is when I removed the drawRect method (hence not overriding it), it somehow fixed the problem I described above.

Can anyone shed some light on this? Is it not safe to override a view’s drawRect method when you are drawing in openGL? Why does it work on the simulator and an older ipod touch?

  • 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-24T10:09:33+00:00Added an answer on May 24, 2026 at 10:09 am

    You’re seeing an artifact that’s due to the differences in points and pixels on a newer device with a Retina display. As I describe in my answer here, UIKit does its sizing using points, which have a 1:1 mapping to pixels on the older devices, but now have a 1:2 mapping on current Retina display ones.

    OpenGL ES, instead, uses pixels for its measurements, which is why you are seeing 640×960 being returned when querying its backing size. This is the size that should be used for the viewport for your OpenGL ES scene.

    I’m guessing that somewhere in the code you’re trying to run is something that sets the viewport for your OpenGL ES scene to be the size in points of your view or layer, rather than the appropriate size in pixels. This causes it to shrink to only one quarter of the view, like what happened in the case of my linked answer above. Look for glViewPort() and related calls, and make sure they are using the backing width and height, and not the view or layer width and height.

    -drawRect: should have nothing to do with this, unless somewhere in there is code for setting the viewport size.

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

Sidebar

Related Questions

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
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a text area in my form which accepts all possible characters from
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

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.