QOpenGLContext without QScreen?
I use Qt to create a Crossplatform OpenGL context. I started with a GUI application. Now I want to turn that into a command-line application, that does not try to open any window at all.
My Question: Is there a way to use QOpenGLContext without a QScreen?
Currently, I basically have
QGuiApplication app(argc, argv);
QScreen* screen = app.primaryScreen();
QOpenGLContext* context = new QOpenGLContext;
Why I want to avoid using/creating a Screen:
I want to start my application on several remote machines because the program does some very time consuming computation. Thus, I created a version of my program that does not raise a window.
BUT: When I start the application on a remote machine (ssh -Y remotemachine01 myapp) I only get OpenGL version 2.1.2. When I start the application locally (on the same machine, I have opengl 4.4). I suppose the X forwarding is the problem. All machines run on Linux.
So I need a way to avoid X forwarding. I suppose that QScreen is the reason X forwarding is needed in my application.
Thanks a lot in advance for any idea/help!
I would create a cli that does everything you need and a second GUI application using e.g. QProcess to run the cli and communicate with it. Something like most mplayer GUI are doing
Hope it helps
First, thx a lot for your fast response.
I'm not sure if I understand your suggested approach. How does this help to get an OpenGL context without a window at all, such that I can run my program remotely without the need of X forwarding?
My cli does the following computation:
@for thousands of objects:
randomly modify the geometry of the object
render the generated geometry in OpenGL to a framebuffer object
do some very time consuming computation with all rendered images (common properties, differences, and so forth)@
If I understood you correctly you don't want any GUI on your remote session right ? So making a complete cli allows you to just call it however you want and have your GUI application only where you want/need it
Yes, I don't want a GUI on my remote session. But I want to use the GPU-power of remote PC's, using OpenGL and rendering to Framebuffer Objects.
But recently, I realized, that this seem to be impossible because of the X forwarding. If I understand that correctly, X forwarding means that the OpenGL commands are executed on my local machine. That conflicts with my intention to use the remote GPU's.
I consider using Mesa with software rendering, but I don't know if that helps.
Do you want to use the GPU for image rendering or for computation ?
Unfortunately, for image rendering. Otherwise I could use Cuda or OpenCL.
I'm wondering if there exist a library for graphics rendering in Cuda. Have not found one with a quick Google search.
Do you mean something like the examples "here":http://www.nvidia.com/content/cudazone/cuda_sdk/Graphics_Interop.html ?
With Cuda Graphics Interop one can share memory between Cuda and OpenGL for e.g. do general computation in Cuda and render/visualize the result in OpenGL.
And that is the problem. It still needs OpenGL for rendering.
Besides that, Mesa + OSMesa (for Off-screen Rendering) seems to avoid without X forwarding. But I get only OpenGL 2.1 :(. I need 3.x.