user617123
user617123

Reputation: 473

How to use glDrawTex*

I want to take a .png image and use it as the background for my GLView. I've heard that glDrawTex* was the best way, but I've searched the internet and haven't found a single example of how to use it (at least not one that has worked for me). Any help?

Upvotes: 2

Views: 1669

Answers (1)

Tommy
Tommy

Reputation: 100622

Although the OES_draw_texture extension is a good enough way to draw a background because it may sometimes be a little faster than using geometry, I'd recommend against using it too heavily on the basis that iPhones don't implement it under ES 2 and you don't want to box yourself into a corner.

That being said, something like:

int sourceRect[4] = {0, 24, 8, 16};  // we'll use the rectangle from (0, 24) of
                                     // size (8, 16) in the texture or textures
                                     // that are currently active as the
                                     // source graphic...

// ... by saying as much to OpenGL
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, sourceRect);


// we'll then draw that at (x, y), with nominal depth z, so as
// to cover the screen area (width, height)
glDrawTexiOES(x, y, z, width, height);

Should be correct.

Upvotes: 3

Related Questions