[Sidefx-houdini-list] Drawing text in the viewport

Edward Lam edward at sidefx.com
Tue Sep 13 09:17:38 EDT 2011


Hi Michael,

I'm not sure why you're running into those issues but perhaps I can give 
some info that helps.

 > ISSUE #1: RE_Render::putMultiLineString()
 > -----------------------------------------

setViewportFontOffset() affects the "xmove" and "ymove" parameters of 
glBitmap() while textMove3W() affects the values sent to glRasterPos().

putMultiLineString() tokenizes the input string for rendering by 
separating via new line characters ('\n'). I'm not quite sure how it 
would behave if the string contains carriage return ('\r') characters. 
I'd double-check that you don't have carriage returns.

When calling putMultiLineString(), textMoveW() is called to update the 
raster position. That's likely why it is necessary to call textMoveW() 
again if putLineLineString() is not behaving as you would expect.

 > ISSUE #2: Flying point numbers
 > ------------------------------

The point numbers (and various geometry "decorations") are affected by 
the setViewportFontOffset() values. Try restoring the original viewport 
font offset values before exiting your hook function to the values that 
were set upon entry.

I don't think you should be really touching the viewport font offset 
values though. Just make textMoveW() (or textMoveS()) calls to set the 
raster position before calling putString() or putMultiLineString(). To 
move to the next line, you should only need something like this:

r->textMoveW(
   r->getRasterX(),
   r->getRasterY() - r->getViewportFont()->getHeight());


Best Regards,
-Edward

On 13/09/2011 5:54 AM, Michael Scarpa wrote:
> Hello there,
>
> I'm writing a render hook that is supposed to draw some geometry (lines) and some text in the viewport.
>
> I am using RE_OGLRender::textMove3W() to get to the correct position in 3D space, where I want my text to appear, and then RE_Render::putString() to draw a string.  This works fine.
>
> I am having two issues though, which I cannot figure out, so if anyone with experience with this could shed some light on the situation, that would be much appreciated.
>
> Houdini version is 11.0.535 and I am stuck with this version for production.
>
> ISSUE #1: RE_Render::putMultiLineString()
> -----------------------------------------
> This does not work.  It draws the first line correctly, but all other lines do not appear.  I have resorted to converting the string into an UT_String, tokenising it to split out the different lines into a UT_WorkArgs object, and then looping over the items and passing each line to a separate call to RE_Render::putString(), while using RE_OGLRender::setViewportFontOffset() to offset the separate lines, so they appear underneath each other (RE_Font::getHeight() gives me the amount of pixels to use for the offset).
>
> Additionally, I found that before drawing each line, I have to call RE_OGLRender::textMove3W() again, even though the coordinates do not change.  If I omit that, again, only the first line of text appears (I suspect the rest of the lines are drawn at completely different positions in space).  Why do I need to call textMove3W() each time, and why does putMultiLineString() only draw the first line?
>
> ISSUE #2: Flying point numbers
> ------------------------------
> While testing variable expansion in the string I was using to display in my custom render hook, I found that, when I move my geometry such that some of its points are not in view anymore, and at the same time point number display is turned on, the text of these points  starts flying over the viewport in the opposite direction.
>
> For example: I move the geometry towards the left edge of the screen.  The moment the first point goes off screen, its number starts flying towards the right, at a higher speed than I am panning the point, until it goes off screen to the right.
>
> At first I thought I was doing something wrong with the drawing instructions in my code, so I started commenting out various sections of my code in an attempt to find the offender.  This resulted in me eventually commenting out my entire code, resulting in empty GR_RenderHook::renderWire() and RE_RenderHook::renderShaded() implementations, and yet the problem still occurs.  So it seems I am missing to do something important rather than doing something I should not, but what is it?
>
> As I said: any help would be much appreciated.  Thanks.
>
> With kind regards,
>
> Michael
>
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list




More information about the Sidefx-houdini-list mailing list