Following code produces an empty image and I cannot figure out what’s wrong:
#! /usr/bin/env python3
from panda3d.core import *
loadPrcFileData('', 'audio-library-name null')
loadPrcFileData('', 'load-display pandagl')
loadPrcFileData('', 'win-size 640 480')
loadPrcFileData('', 'window-type none')
from direct.showbase.ShowBase import ShowBase
gvd = GeomVertexData('', GeomVertexFormat.getV3(), Geom.UHStatic)
gvw = GeomVertexWriter(gvd, 'vertex')
gvw.addData3(0, 10, 0)
gvw.addData3(5, 10, 5)
gvw.addData3(5, 10, 0)
gt = GeomTriangles(Geom.UHStatic)
gt.addVertices(0, 1, 2)
gt.closePrimitive()
g = Geom(gvd)
g.addPrimitive(gt)
gn = GeomNode('')
gn.addGeom(g)
np = NodePath(gn)
class MyApp(ShowBase):
def __init__(self):
super().__init__(self, windowType = 'offscreen')
self.camera.setPos(0, 0, 0)
self.camera.lookAt(0, 10, 0)
np.reparentTo(self.render)
self.graphicsEngine.renderFrame()
self.graphicsEngine.flipFrame()
self.win.saveScreenshot('offscreen.png')
app = MyApp()
Using np = self.loader.loadModel(...)
instead within __init__
before reparendTo()
line works fine.