忍者ブログ

Py淡 (PyTan)

Home > ブログ > > [PR] Home > ブログ > Panda3d > Using buffer protocol to dynamically texture with 2D numpy array in Panda3d

[PR]

×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

Using buffer protocol to dynamically texture with 2D numpy array in Panda3d



I followed this official blog post "Buffer protocol support" and came up with a short example of simple video player in panda3d using numpy 2d array as texture. The trick was to use setRamImage on Texture object. To do that, we have to setup the memory layout using setup2dTexture method.

setup2dTexture ( int x_size, int y_size, Texture::ComponentType component_type, Texture::Format format )

Texture format and Texture componentType need to be set correctly. By try and error, I figured that the combination of T_unsigned_byte and F_luminance works for 8 bit gray scale image.

PR

Comment0 Comment

Comment Form

  • お名前name
  • タイトルtitle
  • メールアドレスmail address
  • URLurl
  • コメントcomment
  • パスワードpassword