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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:37:02+00:00 2026-05-18T12:37:02+00:00

I recently satrted learning OpenGL, and it seems pretty intuitive so far, but this

  • 0

I recently satrted learning OpenGL, and it seems pretty intuitive so far, but this I am stuck on. How can I change the settings so that OpenGL uses a pixel based coordinate system instead of what it uses now. For instance this code draws a rectangle about 10×20 pixels:

glBegin(GL_QUADS); {
     glVertex3f(player.x, player.y, 0);
     glVertex3f(player.x+0.05, player.y, 0);
     glVertex3f(player.x+0.05, player.y+0.1, 0);
     glVertex3f(player.x, player.y+0.1, 0);
}

How can I make it so that this code:

glBegin(GL_QUADS); {
     glVertex3f(player.x, player.y, 0);
     glVertex3f(player.x+10.0, player.y, 0);
     glVertex3f(player.x+10.0, player.y+20.0, 0);
     glVertex3f(player.x, player.y+20.0, 0);
}

would produce basically the same thing? Thanks.

EDIT: I saw someone suggest using glOrtho() somewhere, but they didn’t give any info on how to do that. Would this work, and if so, how would I do it?

  • 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-18T12:37:03+00:00Added an answer on May 18, 2026 at 12:37 pm

    Sorry if I sound brief; it turns out that Safari on the iPad throws away your typing when it does one of it’s probably memory warning induced reloads.

    Assumptions: you’ve tagged the question iPhone so you’re talking about Cocoa Touch (with the origin in the top left, positive on the y axis being down). Similarly, you probably want points, not pixels – so 320×480 of them on the screen whether on a retina display or not.

    glOrtho is exactly what you want – see the man page at http://www.khronos.org/opengles/documentation/opengles1_0/html/glOrtho.html. So, you probably want to do this to your projection stack:

        glOrthof(0, 320, 480, 0, 1, 1000);

    And then do this once on modelview:

        glTranslatef(0, 0, -500)

    And submit all future geometry without a z component.

    What that does is set up a viewport with no perspective (ie, z position doesn’t affect object size), with the left edge of the screen at x=0, the right at x=320, the top at y=0 and the bottom at y=480. It arbitrarily puts the near clip plane at a distance of 1 and the far at a distance of 1000, since they have to be somewhere. But then it translates to halfway (okay, not quite exactly) between the two and so if you don’t submit any more z coordinates then all your geometry will be visible and you’ve got some leeway for rotations around y or x if you want them.

    Be warned though: glVertex calls aren’t available on iOS as they aren’t part of OpenGL ES. They’re also deprecated in modern OpenGL. The short version is that they’re really inefficient and hard for a driver to deal with quickly. glVertexPointer is the thing to use, passing in a C array of numbers.

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

Sidebar

Related Questions

I've recently started learning OpenGl through the SB fifth edition, unfortunately got stuck right
I've recently started learning Scala and was disappointed (but not surprised) that their generics
I have recently started learning Silverlight and can't figure out how make this work.
I recently started learning JavaFX. At the moment I can't build any JavaFX project
Recently I have started learning rails and was a little surprised that the default
I have recently started learning C++, but I require a compiler. I have tried
I just recently started learning RoR and found that Prototype.js is a default javascript
Ok, so I recently started learning jQuery, but I'm having trouble with a little
I just recently have started learning about the wonders of **kwargs but I've hit
I recently started learning Java and found it very strange that every Java public

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.