ウィンドウをポップアップせずにレンダリングする単純な OSG オフスクリーン レンダラーを作成しました。
osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
traits->x = 0;
traits->y = 0;
traits->width = screenWidth;
traits->height = screenHeight;
if (offScreen) {
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->pbuffer = true;
} else {
traits->windowDecoration = true;
traits->doubleBuffer = true;
traits->pbuffer = false;
}
traits->sharedContext = 0;
std::cout << "DisplayName : " << traints->displayName() << std::endl;
traits->readDISPLAY();
osg::GraphicsContext* _gc = osg::GraphicsContext::createGraphicsContext(traits.get());
if (!_gc) {
osg::notify(osg::NOTICE)<< "Failed to create pbuffer, failing back to normal graphics window." << std::endl;
traits->pbuffer = false;
_gc = osg::GraphicsContext::createGraphicsContext(traits.get());
}
ただし、ssh
サーバーに接続してアプリケーションを実行すると、実際にはサーバー GPU ではなくクライアント GPU が使用されます。サーバーには 4 つの GeForce GPU があります。に変更しようとしましDISPLAY
たhostname:0.0
が、うまくいきませんでした。
Linux でアプリケーションがクライアント GPU ではなくサーバー GPU を使用するようにするにはどうすればよいですか?