i have searched many hours, but not found how to render a clean, pixel-perfect image on any x,y-position on the screen.
it is very importend for me to render a image without! automatic scaling or aspect-correction, without repositioning oder using filters on it
(hud-functionality).
i.e. i would say: render my pic “car.png” (40x20) on the screen-position x=340,y=400 after you have completed rendering the previous objects on the scene.
renders the pic, but scales it to fit the entire window and the pic shows
“washy”. if i scale the pic down, it has not the correct aspect-ration and it is always washy.
what must i do to render a image without any adjustment from panda3d
on a fix screen-position?
p.s.
or it is possible to use pygame to render 2d-stuff direct in the framebuffer of panda3d?
Though really, I don’t recommend doing it this way. This will be very slow on older GPU’s. (thats why panda automatically rescales the texture to a power-of-two image: because most gpu’s can process that much faster. The setTexturesPower2 is to override that.)
I’ve also solved this in a way that shouldn’t trip up on non power of two hardware but could potentially waste a fair bit of memory. Copy the base class from this topic and create the following subclass:
class ClearPic(Sprite2d):
PIXEL_SCALE = 400
def __init__(self, img):
Sprite2d.__init__(self, img, anchorY="Center", anchorX="Center")
#self.texture.setAnisotropicDegree(2) # Not sure how if you want this.
self.texture.setMinfilter(Texture.FTLinearMipmapLinear)
self.texture.setMagfilter(Texture.FTLinear)
To use it:
car_pic = ClearPic('car.png')
car_pic.node.setPos(0,0,0)
# Clean up the node
car_pic.clear()
del car_pic