views:

330

answers:

2

So I am using Xcode 3.2.1 and am trying to make an iPhone OpenGL ES1 project. The default template for an opengl project is ok, but I have been trying to split the code up so not everything is done per frame on the drawView() call.

I have a seperate setupRC method that sets the lighting, turns on depth test, turns on culling and sets the clear color. This is called on the init of the EAGLView and this works just fine.

I have took the glViewport() and glFrustrum() calls and put them at the end of the resizeFromLayer() method in the ES1Renderer.m file. This gets hit when the app starts and when the app gets resized as it should.

Now the problem is the frustrum's far seems to be messed up, as in all my objects get cut / clipped off. I tried adjusting the camera position and angle and it still all objects are cut / clipped. I increased the far from 1000.0f to 30000.0f and still get the same result. What is crazy is that if i call both the glViewport() and glFrustrum() calls in the drawView() every frame everything looks right. Nothing is clipped and looks like i want it. From everything I've been reading the frustrum and viewport calls only need to be called when the window / gets made and resizes, but If I don't call it every frame in my project it doesn't work. Any ideas?

Thanks In Advance

A: 

In trying to get this frustum/viewport situation worked out in XCode's OpenGL iphone template myself, one resource that was helpful in getting to the bottom of it was:

http://iphonedevelopment.blogspot.com/2009/05/opengl-es-from-ground-up-table-of.html

A: 

I wonder if you might be doing some extra translating somewhere before you start drawing? Maybe you could make sure you do a loadIdentity() before you start drawing everything just to make sure you're starting from where you think you are.