Imagination PowerVR SDK Blog

glDrawTex orientation


#1

I’m working on drawing 2D text on an OMAP35x EVM.  I tried creating a rectangle and using a texture from a FreeType bitmap which almost worked, but I got repeating texture artifacts even after setting GL_CLAMP_TO_EDGE.  Next I tried the glDrawTex extension, which mostly worked except the orientation is portrait (I’d prefer landscape) and the glyph textures are flipped.  This would be easy to fix with glRotate(), but glDrawTex ignores that by design.

Is there an easy way to change orientation?

Thanks!
,
John


#2

>>  but I got repeating texture artifacts even after setting GL_CLAMP_TO_EDGE




 

What kind of repeats ? Are you drawing the rectangle using triangles in the right order ? Please share the vertex array definition and draw calls.

#3

The artifacts might be symptomatic of the downsampling in mipmaps causing letters to bleed into each other. Make sure that you’re drawing with a 1 to 1 mapping of texels to pixels. You could possibly solve your problem with glDrawTex by orienting your bitmap and adjusting your drawing routine accordingly.

Pete


#4

It turns out the problem with repeating textures was with the glTexImage2D() call.  Both texture data format parameters were GL_RGBA, but had to be GL_LUMINANCE_ALPHA.  The resulting visuals made it look like a clamping problem.

I was able to transpose bitmap rows and columns and got the desired landscape orientation.

Thanks!
,
John


#5

You can specify the sub-rectangle of the texture you want to use with glDrawTex by setting the texture parameter GL_TEXTURE_CROP_RECT_OES. By using negative width or height there you can also flip the texture orientation:





GLint crop_rect[] = { 0, 0, -64, -64 }; // (u, v, width, height), in texels


glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop_rect);


#6

That’s good to know.  Thanks!
,
John