Wednesday, August 1, 2018

Updating OpenGL ES 1.1 based iPhone game to use Open GL ES 2.0


I'm fairly new to anything OpenGL in general. I've made an OpenGL ES 1.1 based 2D iPhone game by working from sample code. I'm under the impression that OpenGL ES 2.0 is substantially different from 1.1. So what does updating 1.1 code to 2.0 entail?


I'm accustomed to the kinda basic drawing pattern of "push matrix, translate, rotate, draw 2D texture, pop matrix". What's the "equivalent" in 2.0?



Answer



OpenGL ES 2.0 is very different from ES 1.1. You don't have a fixed-function pipeline anymore, so your familiar "push matrix, translate, rotate", etc are all gone.


Instead, you have the concept of shaders: vertex and fragment. They're little programs that get executed for each vertex and each pixel. That's where all the transformation and other effects happen. Your code will prepare the vertex data, tell OpenGL how it's structured, and hand it over to the shaders.


But not all is lost: Some parts of OpenGL haven't changed, like setting different states (blending modes, depth comparisons) or creating textures.


To use OpenGL ES 2.0 effectively you need to master the basics of 3D computer graphics, so get a good intro book and learn the principles. Then you can move on to OpenGL ES 2.0 and start writing shaders. This is a good OpenGL ES 2.0 book.


Finally, don't assume you have to move to OpenGL ES 2.0. Unless there's something specific you need that you can't do in ES 1.1, you can continue using ES 1.1 because newer devices are all backwards compatible.



No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...