View Full Version : drawText on opengl image

Bystrov Sergey
11-24-2009, 11:10 AM

I display live video using OpenGl. So, I do YUV=>RGB transform on GPU and display it, using shaders. Evrything works fine until I want to draw some text on the video (like fps or smth).
I've looked at QT example opengl/overpainting. But it does't work in my case. It seems like drawText/renderText uses the same mechanisms to draw text as I use to draw video.
So as the result I do not see text at all. But at the same time I can draw lines on the video and smth like that... I'm not very good ( not good at all in GL). So can you please help me.

Here is minimized code( it is still big, sorry for that)...

http://www.qtforum.org/index.php?page=At...374cde0ba5a6030 (http://www.qtforum.org/index.php?page=Attachment&attachmentID=2254&h=4c75 0b3dca51fc00870820064045d6a62d5a1673&s=063f76f46e6 db00ad2566a843374cde0ba5a6030)


I think that my shaders some how corrilates( broke ) with renderText.

11-25-2009, 01:32 AM
What about disable GLSL programs before draw text,

then reenable after ?

Bystrov Sergey
11-25-2009, 12:27 PM
Thank you for replay!

glUseProgram(0) does not help.
Am I doing smth wrong?

At very begining I did

glUseProgram = (_glUseProgram) QGLContext::currentContext()->getProcAddress(QLatin1String("glUseProgram"));

after that befor draw text I call glUseProgram(0);
But text still not visible.

Even more than that...

I call glUseProgram(0) right after

glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_program[prog]);

The video is still fine so, sharders works in spite of glUseProgram(0). And glGetError after glUseProgram(0) returns 0.

From other hand if I do not call glDisable(GL_FRAGMENT_PROGRAM_ARB) after I finished draw frame I can see the text but it's not very well displayed ...

Bystrov Sergey
11-27-2009, 12:57 PM
Problem is solved by adding glPushAttrib(GL_ALL_ATTRIB_BITS);
and glPopAttrib();