draw text in opengl viewport?

shoei321shoei321 Posts: 29
edited December 1969 in DAZ SDK Developer Discussion

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

Comments

  • rbtwhizrbtwhiz Posts: 436
    edited December 1969

    Dz3DViewport inherits QGLWidget. QGLWidget provides renderText().

    -Rob

  • shoei321shoei321 Posts: 29
    edited December 1969

    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

  • rbtwhizrbtwhiz Posts: 436
    edited December 1969

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

    -Rob

  • shoei321shoei321 Posts: 29
    edited December 1969

    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

  • shoei321shoei321 Posts: 29

    I'm still trying to find a way to render text to the viewport -- I'm calling the QGLWidget::renderText() method as described above, but I am getting a linker error during the MOC compile.   I've included QGLWidget, qgl.h, which declares the renderText() method, but for some reason MOC is not seeing it?   Any suggestions on how to get this to build?

     

    Error    1    error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl QGLWidget::renderText(int,int,class QString const &,class QFont const &,int)" (__imp_?renderText@QGLWidget@@QEAAXHHAEBVQString@@AEBVQFont@@H@Z) referenced in function "public: virtual void __cdecl MyClass::draw(class DzDrawStyle const &)const " (?draw@MyClass@@UEBAXAEBVDzDrawStyle@@@Z)    MyClass.obj   

     

     

    Thanks!

     

Sign In or Register to comment.
Rocket Fuel