is there a way to put text on screen other than onscreentext

onscreentext looks good , but it’s sucking much CPU time.
i have seen some game with a lot of text updating on screen every frame (update rate of 100fps or so). maybe that’s another technique to put text on screen.

is there another way in Panda3D?

I can think of two causes. One can be that you are using vector based TTF fonts, which need to be converted to pixels before rendering.
Another thing could be that in OnscreenText makes a quad for each letter which aren’t merged to one in the end and maybe you are sending too much geoms to the GPU each frame. There might be a way to tell that you don’t want to modify the text in the constructor or something. There are other solutions like rendering all the characters to an offscreen buffer and applying the buffer as a texture to a one big quad, but I think Panda3d has a high level solution to your problem.

You could use a Text Node (which is the component wrapped by OnscreenText, so you might still observe performance issues, if the problem is there). Anyway, I never noticed any noticeable performance issue with text, could you explain your problem more in details, please?

sorry i made a mistake here.
i used to misunderstood the performance hit when i haven’t establish the system, and set the text update rate of every half second.
now my program has stable framerate (about 40fps), and i just tested the text update rate of updating every frame. there is no noticable performance hit.
it is good now.

but the PandDX9 rendering performance is odd on my PC. i have other 3D game rendering with DX9, and there are a lot of objects/effects in the game, the game runs at 50fps without much problem.
now in Panda, even if there is no objects in the scene, it can run at 40fps or so. while Opengl gives me 100fps frame rate.
i also tried DX8, the frame rate is also 40, and it’s stuttering badly. so i have to use DX9 now, as OpenGL has fog problem on my PC.

the sync-video option also gives me trouble, with it off, i have stuttering framerate with any render API. i have to set it on.
my screen is LCD with refresh rate of 60hz.

What kind of graphics card do you have? This is the first time I’ve heard of either problem. It sounds like it might be a driver issue to me. (I know that you’ve said other applications run fine in DX9 mode, but that doesn’t rule out a driver issue–the interplay between the graphics engine and the driver is really quite complicated.)

Have you tried updating your graphics driver from your graphics card manufacturer’s website? The OpenGL issue, at least, is almost certainly a driver issue that should be corrected with a fresh driver.

David

my graphic card is the onboard ATI 9600 on a HP NC6000 laptop. i use the official driver from HP. the driver is really old but i don’t want to update to unofficial drivers from other manufacturer.
because my graphic card can display correctly in almost every game including DX series and Opengl except those requiring shader 3.0 , i am quite comfortable using the graphic driver.

i just found out the stuttering was caused by setting the clock-frame-rate .
when it’s limited to a lower number(50fps) than max achievable framerate(about 90fps), i have to enable sync-video to eliminate stuttering. but then the performance(40fps) would be lowered by large in DX mode, while in Opengl mode the performance is still high (output 50fps, just like the limited number).

now i set the clock-frame-rate at 100.0 and sync-video off. i get 90 fps in DX9. i am satisfied with this framerate. so i decide to use only DX9 now.

sorry that i dig up this old post. but OnScreenText really has big impact on my system.

currently i have 7 text objects which can be toggled and modified. and a function that update the 7 text objects, like this:

version1 of code updates each text object individually at different graphic frames

i=frameid # where frameid cycling from 1 to 30
qty=len(camtxt) # qty equals to 7
while (i>=qty):
    i-=qty
    camtxt[i].setText(str(int(round(camset[camID][i])))) # where camset stores camera position and hpr values

version2 updatas all text objects at once when frameid is 5,10,15,20,25,30

i=int(frameid)
if (i==(i/5)*5):
    i=len(camtxt)-1
    while (i>=0):
        camtxt[i].setText(str(int(round(camset[camID][i]))))
        i-=1

my framerate display is constantly showing 30, but,
i have a function which rolls the camera at constant rate, to let me see the rendering speed -
when i use version2 of code, i can see obvious stuttering, must be caused by updating the texts;
when i use version1 of code, i don’t see stuttering.

my scene is really simple, containing just a flat sea surface made of 2 triangles.
so it’s obvious that updating 7 text objects at the same frame takes up much time, while version1 of code evens out the time required to update the texts.

maybe people with high-spec PC don’t notice the performance impact of OnScreenText, but does someone with low-spec PC ever got the similar problem?

additional info:

  1. it doesn’t matter whether i use font from ttf(arial.ttf) file or from egg file(cmtt12.egg).
  2. if the texts are turned off, CPU usage is around 10%. it rises to around 40% when texts are shown.
  3. my PC has Pentium M 1.7 CPU + 768M ram + onboard ATI 9600 graphic card + WinXP
  4. on the same PC i run a commercial 3D game (DX9 API) which has dozens of text objects all updating at 50fps without problem.
  5. my config for Panda3D:
framerate=30.0
loadPrcFileData('','load-display pandadx9')
loadPrcFileData('','fullscreen 0')
loadPrcFileData('','sync-video 0')
loadPrcFileData('','clock-mode limited')
loadPrcFileData('','clock-frame-rate '+str(framerate))

one more info:
in the commercial game i refered to, the texts can’t be transformed or rolled or slanted. they can have shadow or outline effects.
i guess that kind of text is achieved by different methods than Panda3D’s OnScreenText. i don’t know much about the low-level stuff of graphics rendering though.
i just wish Panda3D has that kind of text object for high performance.

It is true that Panda’s underlying TextNode class (which is what OnscreenText uses to generate text) will by default aggressively compute the optimal text representation at the time it is generated. This is done on the assumption that the text will be generated once, and then largely left unchanged.

If you are modifying your text frequently, you may prefer to leave the text in a suboptimal form. This means that it will spend less time to generate the text in the first place (but it might be a bit slower to render on subsequent frames). On the other hand, these per-frame optimizations are really only a benefit for modern graphics hardware; on a low-end system like yours, it will probably render equally fast with or without them.

So, you can disable these optimizations. You can experiment with setting either or both of these config variables:

text-flatten 0
text-dynamic-merge 0

You can also set this on a per-TextNode basis with TextNode.setFlattenFlags().

David

Thank you so much. these 2 settings totally removed the stuttering problem.