Errata

iPhone 3D Programming

Errata for iPhone 3D Programming

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Other Digital Version
1
code example


Not an errata, but a code example issue. In ApplicationEngine.cpp (in the texturefilter example, and others),

visuals[0].LowerLeft = ivec2(-160, 0);

should be

visuals[0].LowerLeft = ivec2(-m_screenSize.x/ 2, 0);



Note from the Author or Editor:
Yes, the book should be using the passed-in screen size rather than a hardcoded size. Good catch.

Anonymous  Apr 27, 2010 
Other Digital Version
1
VertexSkinning code sample, RenderingBase::GenerateBoneData

Bone generation of indexes is incorrect in the case when there are 9 matrix units (1st gen iPod) - in which case the { i0++;i1++;} code can overflow and produces '9' as a result in some cases.

The result is some vertices are skinned to the wrong position and thus a somewhat distorted stick figure.

Note from the Author or Editor:
Yes, the skinning example does not work properly with OpenGL ES 1.1. Unfortunately this is due to a fundamental flaw in the code, so the fix is too involved to be conveyed here. For the second edition, we will remove the ES 1.1 variant of this sample.

Anonymous  May 18, 2010 
1
Last sentence under heading "Example 1-2. EAGL initialization in GLView.mm"

This is the sentence which I think has the error.

Replace the OpenGL Initialization comment with Example 1-3.

I do not see a comment which says "OpenGL Initialization" anywhere in the previous text.

Note from the Author or Editor:
On page 16, the comment that says "Initialize code..." should say "OpenGL Initialization".

Anonymous  Jul 17, 2010 
PDF
Page 11
Bottom (last sentence)

You state that Apple "advises against mixing UIKit with OpenGL" - this is entirely incorrect. I'm not 100% positive that it wasn't the case when you wrote this, but at this year's WWDC, they have been very clear that taking advantage of UIKit on top of your OpenGL view is something they encourage. Can't go into too much detail because of the NDA, but there were extensive demos to get this point across.

Note from the Author or Editor:
Yes, that sentence is outdated. The impact of that sentence is hopefully mitigated by the note at the top of the following page.

It's fine to mix UIKit with OpenGL nowadays, and we hope to make heavy use of this fact in the second edition.

Anonymous  Jun 09, 2010 
Printed
Page 13
Note

The layer object is an instance of CAEGLLayer...
should be
The layer object is an instance of CAEAGLLayer...
(missing A)

Note from the Author or Editor:
Yes, CAEGLLayer should be spelled "CAEAGLLayer".

Anonymous  Sep 21, 2010 
PDF
Page 36
Bottom

EAGLRenderingAPI api = kEAGLRenderingAPIOpenGLES2;
m_context = [[EAGLContext alloc] initWithAPI:api];

I think this code should change to:

EAGLRenderingAPI api = kEAGLRenderingAPIOpenGLES2;
if ( !ForceES1)
m_context = [[EAGLContext alloc] initWithAPI:api];

If device supports ES 2.0 and the ForcesES1 is set true, EAGLContext object with ES2 API is allocated but not used.

Note from the Author or Editor:
Yes, this results in a minor memory leak. Good catch!

Kenny  Jun 05, 2010 
PDF
Page 90
Top

The array size is incorrect.

vec2 vertices[6] = { vec2(0, 0), vec2(0, 1), vec2(1, 0), vec2(1, 1) };
=> vec2 vertices[4] = { vec2(0, 0), vec2(0, 1), vec2(1, 0), vec2(1, 1) };

The description following this code is also wrong.

That's only 48 bytes,
=> That's only 32 bytes,

Note from the Author or Editor:
Good catch! Your corrections are spot on.

Anonymous  Jun 05, 2010 
PDF
Page 99
2nd Paragraph

I decided to follow the book and I was going to download WireframeSkeleton project.
But there is no project like that on your web site.

Could you please upload that skeleton project?

Note from the Author or Editor:
I recently added the WireframeSkeleton project to the downloadable samples: http://bit.ly/b5ZqHd

Anonymous  Jun 06, 2010 
PDF
Page 204
right before aside

Using strstr isn't quite kosher. For example, checking for GL_ARB_shadow with strstr will bite you if you have GL_ARB_shadow_ambient.

Philip Rideout
 
Jan 23, 2011 
PDF
Page 227
9th line from below

(The explanation of the constant GL_FUNC_ADD)
Adds the source operand to the source operand; this is the default.
=>
Adds the source operand to the destination operand; this is the default.

Note from the Author or Editor:
Good catch Kazuya.

Kazuya Abbey  Aug 07, 2010 
PDF
Page 242
Example 6-10

There is no need to call glRenderbufferStorageOES as the space has already been allocated by the associated texture object. Thanks to Douglass Turner for catching this.

Philip Rideout
 
Jan 23, 2011 
Printed
Page 255
1st & 2nd lines

Sorry but I posted an error in my suggested correction to the 1st and 2nd lines on page 255.

vec3 a = lines.Vertices[lines.Indices[*sourceIndex++]].Position;

vec3 b = lines.Vertices[lines.Indices[*sourceIndex++]].Position;



should change to



vec3 a = lines.Vertices[*sourceIndex++].Position;

vec3 b = lines.Vertices[*sourceIndex++].Position;

Note from the Author or Editor:
Good catch! In the downloadable "AaLines" sample, sourceIndex is an integer rather than iterator, so I mixed up the listing in the book. Thanks!

Elliot  Jul 06, 2010 
Printed
Page 348
Fisrt line below Figure 8-7.

OpenGL does expect it when you give it the image data for a cube map.

should read:

OpenGL doesn't expect it when you give it the image data for a cube map.

Note from the Author or Editor:
Good catch Kazuya.

Kazuya Abbey  Nov 05, 2010 
Printed
Page 374
3rd line from the bottom

the GPU can take the cross product of two edges

should go:

the GPU can take the dot product of two edges

because a cross product results in a vector which has no sign. The GPU should take the dot product of the two edges producing a scalar value which represents the angle between them.

Note from the Author or Editor:
It's true that this sentence needs clarification, but a dot product would be incorrect. The actual correction is changing "if the resulting sign is positive" to "if the resulting sign of the Z component is positive".

Kazuya Abbey  Nov 06, 2010 
Printed
Page 398
frustum function

I had posted earlier in this errata that there was a rendering difference between the ES1 and ES2 versions of the example programs, and I explained how to illustrate this difference by setting up constants for the HelloCone project that make the discrepancy more obvious. I believe I have since figured out the root of the problem. In the function listed in the appendix:

static Matrix4<T> Frustum(T left, T right, T bottom, T top, T near, T far)

The last statement should be m.w.w = 0; NOT m.w.w = 1 (as the book and online appendix state). When I made this change, the ES1 and ES2 renderings were identical, instead of there being slightly off clipping and zooming in the ES2 version.

I am almost positive that this is correct as my program confirms it. I hope the author has a chance to read this over and confirm it himself so that I can move forward from chapter 2, confident that I have made the right change!

Note from the Author or Editor:
In Matrix.hpp (listed in the Appendix), change the Frustum method so that it sets m.w.w to zero rather than one.

Paul  Jul 15, 2010 
PDF
Page 401
United States

There is a discussion on Stack Overflow about the function QuaternionT<T>::CreateFromVectors in the book's vector library, and whether the line with if (v0 == -v1) is in fact correct. The SO question is here: http://stackoverflow.com/questions/15355102/why-is-my-cube-distorted#comment21702236_15355102

Note from the Author or Editor:
Yes, the "if" statement needs to be tweaked so that it finds a properly perpendicular axis, rather than choosing a random axis. Good catch!

sebby  Mar 12, 2013