rexsj
Posts: 16
Joined: Tue Dec 11, 2012 8:43 am

Draw text on opengles

Fri Jan 18, 2013 10:04 am

Hi there,
I have been trying to render text on screen alongwith images. Tried many things, but it dont seem to be fine. After googling also, nothing seems to fit the requirement (also i dint understand much :( ).
Plss help........ I am trying to create menubar like tool on opengles something similar to xbmc home menu, i dont know in which direction to start.....
Thanks for any suggestions or hints.

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Draw text on opengles

Fri Jan 18, 2013 12:03 pm

One way is to render the text into a bitmap and use that as a texture.
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

rexsj
Posts: 16
Joined: Tue Dec 11, 2012 8:43 am

Re: Draw text on opengles

Sat Jan 19, 2013 1:29 pm

Thanks for ur reply ......i tried it and i find it a convenient and good way :)
But is this a proper way, if i have to add too many bitmaps for every word, since every bitmap must receive input from user?
i see other trials on google.....dont know if it will work on the pi....seems complicated!!
Thanks for any guidance

User avatar
PeterO
Posts: 5829
Joined: Sun Jul 22, 2012 4:14 pm

Re: Draw text on opengles

Sat Jan 19, 2013 2:01 pm

rexsj wrote:Thanks for ur reply ......i tried it and i find it a convenient and good way :)
But is this a proper way, if i have to add too many bitmaps for every word, since every bitmap must receive input from user?
i see other trials on google.....dont know if it will work on the pi....seems complicated!!
Thanks for any guidance
I'm unsure what you are trying to achieve by using a bitmap for each word. I would render all the text into a single bitmap OR use one texture to hold the font and one to hold the text as detailed here: http://www.raspberrypi.org/phpBB3/viewt ... 20#p253758

PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

rexsj
Posts: 16
Joined: Tue Dec 11, 2012 8:43 am

Re: Draw text on opengles

Thu Jan 24, 2013 1:37 pm

Will try that!! thnks
I had this doubt since long time..........Is it possible to display 32 bit image with transparency on opengles?.I dint seem to get it right, so converted it to 24 bit to render it on screen, but it losses the alpha. I believe 32bit images are not supported on OpenGLes.....is it right?

rexsj
Posts: 16
Joined: Tue Dec 11, 2012 8:43 am

Re: Draw text on opengles

Thu Jan 31, 2013 8:52 am

Solved the issues.........
for 32 bit images, i used RGBA and for text , i used a single bitmap for background and other bitmaps to construct application menu.
This is the solution for creating a menu ............. i hope?? pls give me ur suggestions :(
For background image, i am trying to use "glDrawTexfOES" but texture renders on the screen with no image,why this is happening? i tried changing all the parameters...........the position and dimensions seem to change but it is blank :?

User avatar
Paeryn
Posts: 2952
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: Draw text on opengles

Thu Jan 31, 2013 8:44 pm

rexsj wrote:Solved the issues.........
for 32 bit images, i used RGBA and for text , i used a single bitmap for background and other bitmaps to construct application menu.
This is the solution for creating a menu ............. i hope?? pls give me ur suggestions :(
For background image, i am trying to use "glDrawTexfOES" but texture renders on the screen with no image,why this is happening? i tried changing all the parameters...........the position and dimensions seem to change but it is blank :?
You need to set the crop rectangle before glDrawTex to define the area of the texture that will fill the drawn rectangle

Code: Select all

int crop_rect[4] = {x, y, width, height};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop_rect);
glDrawTexiOES(50, 50, 0, 100, 100);
This will draw the texture to a 100x100 square with it's lower-left corner at 50,50,0.
Don't forget that gl's origin is lower-left (i.e. the top line of the texture will be draw at the bottom), if your image appears upside down you can set the crop rectangle to {x, y+height-1, width, -height}.
She who travels light — forgot something.

rexsj
Posts: 16
Joined: Tue Dec 11, 2012 8:43 am

Re: Draw text on opengles

Mon Feb 04, 2013 9:48 am

Thanks..............it helped :D

Return to “OpenGLES”