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.

Trouble porting OpenGL code to iPhone's OpenGL ES

Hi friends,
I am new to OpenGL..

Here, is the sample code which I am using. This code is in OpenGL. I want to convert it to OpenGL ES. glArrayElement() is not supported in OpenGL ES. Instead, it was recommended to use glDrawElements(), glDrawArrays(). I am not able to convert this. Can you please help me out to convert the code.

Re: Trouble porting OpenGL code to iPhone's OpenGL ES

You simply need to create an index array which contains the index values you pass to glArrayElement, then pass that index array as a whole to glDrawElements. Of course as long as your vertex order stays constant you need to create this index array only once. In addition, you can stitch triangle strips together with degenerate triangles in order to reduce the number of draw calls since they have some overhead.

And one more question is do we have any replacement for glEnable(GL_TEXTURE_RECTANGLE_EXT) in OpenGL ES.

Textures need to have power-of-two dimensions and use normalized texture coordinates. You could pad your rectangle textures to the next higher power of two and scale the texture coordinates accordingly.

Re: Trouble porting OpenGL code to iPhone's OpenGL ES

Thanks alot. The code which you have sent is working fine. Thank you very much...

Can you please help me out in my other question. Iam still strucked with glEnable(GL_TEXTURE_RECTANGLE_EXT).
I am using glEnable(GL_TEXTURE_2D) instead of glEnable(GL_TEXTURE_RECTANGLE_EXT) for texture image. Iam not getting the same image. I am not able to fix this...

I have converted the above code to OpenGL ES in this way :
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,backtex);
glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MO DULATE);
glMatrixMode(GL_TEXTURE);