The Khronos Group - a non-profit industry consortium to develop, publish and promote open standard, royalty-free media authoring and acceleration standards for desktop and handheld devices, combined with conformance qualification programs for platform and device interoperability.

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Problem when moving object in Z coord...

Hello!
I'm starting to play around with OpenGL ES 2 and when trying to move an object in the Z coord it just either disappears or doesn't do anything.
It moves well in X and Y but not Z.
To move in Z I use the gl_Position.z in the shader.

The source of the project is in: http://cl.ly/24240x2D1t2A3I0c1l1P
It's a XCode project for iOS, the setup code can be found in EAGLView.m @ createFramebuffer, and the draw code can be found in TranslateSinZ.m @ drawView.

I believe the problem should be in the setup code but I can't figure out what's wrong...

Re: Problem when moving object in Z coord...

gl_Position is the position of the vertex in homogeneous clip space. Its Z component is only used for clipping against the near and far planes as well as for the depth test. It does not affect the position of the vertex in X and Y on screen.

I suspect that what you actually want is to translate the vertices in view space Z, before applying a projection transformation.

Re: Problem when moving object in Z coord...

I thought just changing the value in "gl_Position.z" would work since it works for "gl_Position.x" and "gl_Position.y".
So to translate the rectangle in Z, how can I achieve that?
"Translate the vertices in view space Z" can you explain in another fashion?
Thank you for your time.

Here, translations and rotations for a given model are loaded into the model matrix, m_model , the camera setup is loaded into the view matrix, m_view and the projection (ortho or perspective) is loaded into the projection matrix m_projection .