Gustavo
Gustavo

Reputation: 795

Convert code in Opengl es 1.0 to Opengl es 2

This is the code:

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mFont->mTexId);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

// Bind our vertex data
glVertexPointer(2, GL_FLOAT, 0, mVertices);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, mUVs);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

// Draw the text
glDrawElements(GL_TRIANGLES, 6 * mNumberOfQuads, GL_UNSIGNED_BYTE, mIndices);

I tried with the next code, but it is not working, the problem is that I´m beginning to learn Opengl Es and I don´t understand a lot of things.

 // Enable texturing, bind the font's texture and set up blending
 //glEnable(GL_TEXTURE_2D);
 glBindTexture(GL_TEXTURE_2D, mFont->mTexId);

 //glEnable(GL_BLEND);
 //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

 // Bind our vertex data
 //glVertexPointer(2, GL_FLOAT, 0, mVertices);
 //void VertexPointer(int size,enum type,sizei stride, void *pointer );


 glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 20, mVertices);
 //void VertexAttribPointer( uint index, int size, enum type, boolean normalized, sizei stride, const void *pointer );
 //glEnableClientState(GL_VERTEX_ARRAY);
 //glEnableVertexAttribArray(VERTEX_ARRAY);



 // glTexCoordPointer(2, GL_FLOAT, 0, mUVs);

 //glEnableClientState(GL_TEXTURE_COORD_ARRAY);

 // Bind the VBO so we can fill it with data
 glBindBuffer(GL_ARRAY_BUFFER, 2);
 // Draw the text

 glDrawArrays(GL_TRIANGLES,  0, 6 * mNumberOfQuads);
 //void DrawArrays( enum mode, int first, sizei count );

 //glDrawElements(GL_TRIANGLES, , GL_UNSIGNED_BYTE, );
 //void DrawElements(enummode,sizeicount,enumtype, void *indices );*/

Upvotes: 1

Views: 726

Answers (1)

genpfault
genpfault

Reputation: 52082

Try compiling and binding a vertex and pixel shader before you submit your geometry. There's no fixed-function pipeline at all in ES 2.0.

Upvotes: 1

Related Questions