## Appears as an oval

Code:

`- (void)awakeFromNib`

{

NSSize viewBounds = [self bounds].size;

float height = viewBounds.height;

float width = viewBounds.width;

[[self window] setContentSize:NSMakeSize(width, height)];

[[self window] setContentAspectRatio:NSMakeSize(width, height)];

}

Change your projection.

Could you tell how.

No, this is a basic question which is much better served by a tutorial than a forum post. GIYF.

See The OpenGL FAQ, in particular 9.011.

That does not explain how to solve the problem.

(Aug 9, 2010 12:21 PM)Miglu Wrote: I can not find it in OpenGL Programming Guide.

It's in there. Read chapter 3, "Viewing". At least that was the chapter in the third edition. You're looking for information about the projection matrix.

Anyway, you can try this for now, but you really need to study up on how this works:

Code:

`- (void) drawRect:(NSRect)rect`

{

glClear(GL_COLOR_BUFFER_BIT);

// setup projection matrix

glMatrixMode(GL_PROJECTION);

glPushMatrix();

glLoadIdentity();

glOrtho(-MY_ASPECT_RATIO, MY_ASPECT_RATIO, -1.0, 1.0, -1.0, 1.0);

// setup modelview matrix

glMatrixMode(GL_MODELVIEW);

glPushMatrix();

glLoadIdentity();

[self ball];

// pop modelview matrix

glPopMatrix();

// pop projection matrix

glMatrixMode(GL_PROJECTION);

glPopMatrix();

[[self openGLContext] flushBuffer];

}

The first google hit for "OpenGL projection" is pretty helpful: http://www.cprogramming.com/tutorial/ope...tions.html The first function the article mentions, glOrtho(), is the one you are looking for even.

That said, OneSadCookie and arekkusu are right that you need to find a tutorial to explain how projection matrices work, read a bunch of the docs, or both. Otherwise your next question is inevitably going to be what to do with glOrtho(). You are only going to find projections as explained by a larger tutorial such as this one: http://nehe.gamedev.net/data/lessons/les...?lesson=17

This also isn't the direct answer that you were looking for, but hopefully points you a little closer in the right direction.

That said, OneSadCookie and arekkusu are right that you need to find a tutorial to explain how projection matrices work, read a bunch of the docs, or both. Otherwise your next question is inevitably going to be what to do with glOrtho(). You are only going to find projections as explained by a larger tutorial such as this one: http://nehe.gamedev.net/data/lessons/les...?lesson=17

This also isn't the direct answer that you were looking for, but hopefully points you a little closer in the right direction.

Scott Lembcke - Howling Moon Software

Author of Chipmunk Physics - A fast and simple rigid body physics library in C.

Ah, yeah that is a much better tutorial on transformation matrices.

Scott Lembcke - Howling Moon Software

Author of Chipmunk Physics - A fast and simple rigid body physics library in C.

The default matrices are identity.

Ah right, thanks for the clarification.