Jump to content
  • Advertisement
Sign in to follow this  
wisteria23

OpenGL How to render text on Opengl ES 2.0 in Qt 4.7

This topic is 2782 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,
We want to draw date and Time on Opengl ES 2.0 context in QT 4.7.
We have tried doing so using drawText(x,y,Qstring).
following is the code attached for reference.
QPainter painter;
painter.begin( this );
painter.setPen(Qt::red);
painter.drawText(-6.0f,6.0f,QString("Example"));
But it is not being drawn on the Opengl ES context.

We are inheriting this widget class from QGLWidget.
Is this the correct way or there is some other way to draw date and Time on the opengl ES 2.0 context?
Please suggest or provide some link for reference.

Regards,
wisty

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by wisteria23
painter.drawText(-6.0f,6.0f,QString("Example"));

There is no drawText function which takes two floats. Are you sure the coordinate (-6,6) is on the screen?
What is the this is painter.begin( this ) ? Is it the QGLWidget?
Are you use beginNativePainting and endNativePainting when calling OGL functions your self? If you forget that will mess up the rendering of Qt.

Share this post


Link to post
Share on other sites
Hi Kambiz,

We are doing all the rendering in paintGL function.
In this function we are calling painter.begin(this) which is QGLWidget.

We are also calling beginNativePainting and endNativePainting when calling OGL functions.

Also we are giving this ( -6,6) coordinates after considering the positions where we are rendering other objects.

Is there some other Qt class which we can use to render Date and Time?
I know this is not a Qt forum,but in case someone has worked in Qt using Opengl ES 2.0,it would be of great help.

Regards,
wisty

Share this post


Link to post
Share on other sites
I have no experience with OpenGL ES but I had no trouble with Qt and OpenGL up to now. Do the other painting functions work? If yes, maybe there is a problem with loading the font.

Also, where do you draw other objects? (-6,6) may be on screen in the coordinate system of QGraphicsView (if you are using one) but no in the coordinate system of the QGLWidget. How do you setup the coordinate system?

What does QPainter::clipRegion() return? (You can use QRegion::boundingRect() to get the bounding rectangle of the clip region)

Quote:
Original post by wisteria23
Is there some other Qt class which we can use to render Date and Time?
I know this is not a Qt forum,but in case someone has worked in Qt using Opengl ES 2.0,it would be of great help.

Yes, in our engine we use a wrapper around QGraphicsTextItem to display text on the screen. You can find an example of the required wrapper in the boxes demo but I'm pretty sure that the text still get's rendered the same way.

Share this post


Link to post
Share on other sites
HI Kambiz,
Thank you so much for your prompt reply.
I am not sure where the exact problem is.
we are getting all other rendering in place.But only when we try to draw the text, we are not able to render it.
Right now we are giving some random coordinates(based on other drawing coordinates) so that it is atleast visible on the screen.But till now there is no success..

Is there something called as Bitmap font rendering in Qt?

Regards,
wisty

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!