O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

We Have an Aspect Ratio Problem

We’re now pretty familiar with the fact that everything we render in OpenGL gets mapped to a range of [-1, 1] on both the x- and y-axes; this is also true of the z-axis. Coordinates in this range are known as normalized device coordinates and are independent of the actual size or shape of the screen. Unfortunately, because they are independent of the actual screen dimensions, we can run into problems if we use them directly, such as a squashed table in landscape mode.

Let’s say that our actual device resolution is 1280 x 720 in pixels, which is a common resolution on new Android devices. Let’s also pretend for a moment that we’re using the whole display for OpenGL, as it will make this discussion easier.

If our ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required