@AshPowers, thanks for struggling on with various
pi3d quirks; I will add them to the FAQ for the sake of others.
The lack of GPU memory symptoms are so varied they're quite hard to figure out, especially if you're just getting to grips with a new module.
The PointText/TextBlock system that Matt developed is very fast and flexible but also quite complicated, especially hard to follow as the demo tries to showcase all the features! One subtlety that isn't obvious is the fact that 'extra' info is being shoehorned into the array passed to the shader, critically the z value of each vertex (i.e. each character) contains both the depth *and* the size. Coupled with the
use of medium precision floats this means that the behaviour of the depth and size values of TextBlock seem very strange.
Depth as specified in TextBlock doesn't match up with the normal depth of 2D objects such as ImageSprite (this is different from the 2D v 3D depth difference mentioned
here) Keep the TextBlock z values small and the other objects large (i.e. 0.5 may be in front of normal 2D z of 6.0 but behind 5.9 so play safe with a value of 50.0)
Size varies from 0.05 to 0.99 (subject to float precision) however if you use a size of more than 1.0 it will effect the spacing! Try using 0.99, 1.99, 2.99 etc.
Code: Select all
import pi3d
import time
class EgClass(object):
def __init__(self):
self.fps, self.st, self.fr = 0.0, None, None
def update(self):
if not self.st:
self.st = time.time()
self.fr = 0
else:
self.fr += 1
self.fps = self.fr / (time.time() - self.st)
eg_object = EgClass() # create an instance of the example class
DISPLAY = pi3d.Display.create()
CAMERA = pi3d.Camera(is_3d=False)
shader = pi3d.Shader('uv_flat')
pointFont = pi3d.Font('fonts/NotoSans-Regular.ttf')
text = pi3d.PointText(pointFont, CAMERA, max_chars=200, point_size=64)
newtext = pi3d.TextBlock(-200, 200, 0.1, 0.0, 10, data_obj=eg_object, attr="fps",
text_format="fps:{:2.1f}", size=0.99, spacing="C", space=1.1,
colour=(1, 1, 1, 1.0))
text.add_text_block(newtext)
background = pi3d.ImageSprite("textures/PATRN.PNG", shader, w=1920, h=720, z=2)
while DISPLAY.loop_running():
text.regen()
background.draw() # blend edges of text by drawing after background.
text.draw()
eg_object.update()
Paddy