PDA

View Full Version : Please help me, porting question



learning_opengl
08-11-2012, 01:14 AM
I am trying desperatly to port some opengl es 1.0 to opengl es 2.0 code. The reason I am asking here instead of the opengl es forum is because here is a more active forum and the code is very similar to opengl code anyway.

In the original opengl es 1.0 code we have this:
Buffer updated each frame but there is no glBindBuffer calls or any concept of VBO's
The main render function has this:

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, VertexSize, pVertex);
pVertex += sizeof(float) * 3;
glDrawElements(glPrimType, nCount * 6, GL_UNSIGNED_SHORT, ((PyroByte *) pIndexBuffer->GetBuffer()) + 12 * nFirst);
glDisableClientState(GL_VERTEX_ARRAY);

What is the best possible way to go about getting this to work with opengl es 2.0?
I know I need shaders and VBO's but I am just unsure how to implement it all.
If someone could give me some basic step by step plan I would be very grateful thanks.

kyle_
08-11-2012, 02:22 AM
You dont need to have VBO - GLES2 allows to render from clinet memory as well.
The porting should be pretty easy, when you implement your shaders.

glEnableClientState -> glEnableVertexAttribArray
glDisableClientState -> glDisableVertexAttribArray
glVertexPointer -> glVertexAttribPointer

For the shaders you need to learn GLSL, shader setup is pretty easy, but somewhat verbose.

glCreateProgram
glCreateShader (vertex + fragment)
glCompileShader
glAttachShader
glBindAttribLocation
glLinkProgram
glUseProgram

You can have a look at any GL2.0+ tutorial and it should be _mostly_ the same.

learning_opengl
08-11-2012, 06:38 AM
You are the best!
I didnt know it was as simple as that.
Thanks so much this is now solved.