Digital Art Zone

 
     
draw text in opengl viewport?
Posted: 05 March 2014 02:05 PM   [ Ignore ]
Member
Rank
Total Posts:  54
Joined  2010-09-22

I need to draw text labels on elements in the opengl viewport in Daz4.6.  I’m overriding the DzNode draw() method and am able to successfully make other opengl calls, but I am not finding a simple way to draw text.  All the examples that google turns up involve GLUT calls that don’t appear to be available in the Daz SDK environment. 

What is the easiest way to do this?

Thanks

Profile
 
 
Posted: 09 March 2014 11:18 PM   [ Ignore ]   [ # 1 ]
Administrator
Avatar
RankRank
Total Posts:  336
Joined  2003-10-09

Dz3DViewport inherits QGLWidget.  QGLWidget provides renderText().

-Rob

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile
 
 
Posted: 10 March 2014 12:03 PM   [ Ignore ]   [ # 2 ]
Member
Rank
Total Posts:  54
Joined  2010-09-22

Thanks Rob, I gave that a try but with mixed success—it seems to be invoking 2D draw calls on a canvas on top of the 3dViewport. 

Which calls does DazStudio itself use to draw text in the viewport?  For instance, using the universal manipulator tool, if you rotate/translate/scale an object in a scene it draws text next to the manipulator to show how far you’ve moved/rotated/scaled the object.  My sense is that this isn’t done using teh QGLWidget::renderText() method. 

Thanks

Profile
 
 
Posted: 10 March 2014 08:58 PM   [ Ignore ]   [ # 3 ]
Administrator
Avatar
RankRank
Total Posts:  336
Joined  2003-10-09

DAZ Studio, the Universal tool, the tools that derive from it, use exactly this method..

-Rob

 Signature 

- Documentation Center
- Install Manager
- DAZ Studio 4.x
- DSON Importer
- DSON File Format Specification

Profile
 
 
Posted: 10 March 2014 09:22 PM   [ Ignore ]   [ # 4 ]
Member
Rank
Total Posts:  54
Joined  2010-09-22

Ok thanks, I’ll keep tinkering with it.  I read in the QGLWidget docs that this method invokes non-GL native paint calls :

This function can only be used inside a QPainter::beginNativePainting()/QPainter::endNativePainting() block if the default OpenGL paint engine is QPaintEngine::OpenGL. To make QPaintEngine::OpenGL the default GL engine, call QGL::setPreferredPaintEngine(QPaintEngine::OpenGL) before the QApplication constructor.

I tried wrappering my renderText call as described above, but to no avail.  Any chance someone could provide a simple example of this that works in DazStudio?

Thanks

 

Profile