I'd like to render animation with opengl.
I have a script for render and this working with open blender GUI.
I want to run this script (with render.opengl function) from linux command line without X.
I tried some way without success :(
Short answer: Can't be done.
Long answer: For OpenGL to be usable you need a so called render context. OpenGL itself can not create render contexts, that's the job of the display graphics system (X11, EGL/Wayland, etc.).
Mesa's software rasterizer is accompanied with an offscreen render context manager, however using that one must be prorammed specifically, works only with Mesa and Blender doesn't support it!
When launched in windowless mode, Blender doesn't even bother to create a render context.
You can use
export DISPLAY=:0
blender -b your_file.blend -a
Not exactly what you asked, but it will do the trick to if you want to render in a remote machine.
Basically it is going to create the render context in the remote machine, nevertheless the render command itself won't open a GUI
Related
I'd like to use UrhoSharp to build a command-line tool that draws some stuff and saves the output to a PNG file.
I've figured out how to draw what I want in a window, and I can save it (after waiting for a couple of updates) with Graphics.TakeScreenshot. But I'd prefer it to run without showing a window at all, so that I can use the tool in my build pipeline without windows popping up all the time.
I've also figured out that I can start the Urho engine in headless mode by adding AdditionalFlags = "-headless" to my ApplicationOptions. But I can't figure out how to trigger the 3D engine to run in this case, or where the output goes. It looks like the graphics subsystem may not be initialized at all in this mode.
Is there a way to make UrhoSharp render into an offscreen buffer of a specified size? Alternatively, it might be okay if I simply keep the window hidden; is there a portable way to do that?
After some digging through the UrhoSharp and Urho3D source, it looks like this is not possible:
In headless mode, no GPU context is created ("headless" means no GPU, not just no window)
In normal mode, an SDL window is always created. SDL has no portable mechanism for creating a windowless GPU context
I can create my own window before initializing Urho and pass in the OS window handle; but:
For a start that needs some OS-specific code
It has to be an SDL_Window, not any kind of offscreen buffer
I think the best that can be done without modifying Urho and/or SDL is to hide the window as soon as possible. I'm not sure if I can avoid having the window flash onscreen briefly. If I can figure it out I'll comment further here!
I'm writing a cross platform open source Oculus Rift desktop viewer. I decided to start with Linux because I prefer developing on it. I've already got the texture warping working but now I need to capture the desktop to an OpenGL texture. There are other issues I'm not entirely sure how to resolve like rendering the warped desktop to my window while capturing every window except mine. Any clue how I would go about this?
I think your best course of action would be actually to write a fully fledged compositor.
There is the GLX_texture_from_pixmap extension, that allows you to source any pixmap compatible X11 drawable into a OpenGL texture. For a start it might be enough to simply pull the root window (pixmap) as it is into a OpenGL texture. Later you might want to use the Composite extension to redirect windows to off-screen rendering and composite them in 3D space as a stereoscopic picture in the Occulus Rift.
There is an interesting browser framework called Awesomium, which is basically a wrapper around the Chromium browser engine.
I'm interested in using it to redistribute WebGL-based games for the desktop. However Awesomium only supports rendering using a pixel buffer sent to the CPU, even though the WebGL context itself is based on a real hardware-accelerated OpenGL context. This is inefficient for real-time high-performance games and can kill the framerate on low-end machines.
Awesomium may eventually fix this, but it got me thinking: is it possible to search a process for an offscreen OpenGL context and render it directly to a window? This would avoid the inefficient rendering method, keeping rendering entirely on the GPU. I'm using a native C++ app on Windows, so presumably this will involve WGL specifics. Also since Chromium is a multithreaded browser engine it may involve finding an OpenGL context on a different thread or event a different process. Is it possible?
is it possible to search a process for an offscreen OpenGL context and render it directly to a window?
No, it it not possible. If the opengl context is created for the OS buffer, then it is not possible to redirect it to other buffer and other opengl context.
Maybe you can use shared opengl resources (if both opengl contexts are created using such option).
I need to develop an app using Java wrapper for OpenGL LWJGL.The app will run on remote server in a headless mode.I am trying to understand if and how is it possible taking into consideration the fact that GL context in LWJGL (and in other APis) is created via Java UI elements like Canvas etc.In my case I need to be able to init GL context without creating a window as the drawing targets will be FBOs from which the pixel buffers will render to texture. There is one possible solution though already called PBuffer (I guess pixel buffer) object in LWJGL.It indeed doesn't need GL context created via window as it creates it internally.I don't want to use this method both because it is older concept (and weaker ) than Frame buffer object and because I am using OGL 3.3 -> .So I really don't want to mix with any old pipeline legacy.
I have basically 2 questions:
1.Can I create a context without setting up a window to use for FBO based rendering(headless mode) ?
2.If the answer to the first question is negative ,then can I run on the remote server such an app where the windows is still initialized for the sake of context access ?
UPDATE:
The question can be closed.I tested it via first initialization done with PBuffers to set a context.Then FBO rendering works as supposed.
I found the answer on my own. One should set PBuffer first to create headless GL context. Once it is created we can use FBOs to render frames into images.
Occassionally I hit places where I'd want to get an OpenGL framebuffer object, but where I'm not interested about opening a window of any kind.
Is it possible to create an opengl context without attaching it to a window of any kind?
Yes! you can use the desktop window as the window passed to OpenGL- as long as you don't try to display anything on it ;)
Just Call GetDesktopWindow and pass the result as an argument when creating new OpenGL window.
http://www.opengl.org/wiki/Creating_an_OpenGL_Context
According to this Web page, WGL_ARB_create_context can be used to create a context without a window. I have not actually tried it myself. I used freeGLUT to create the context and then rendered off-screen to a framebuffer+renderbuffer. I exit the program without ever calling glutMainLoop. It is klugy, but it works for my purposes.
Yes, you can perform off-screen rendering with OpenGL, but the exact way to set it up is dependent on the operating system.
The closest you get to an OS independent way would be to use Mesa 3D, but then your off-screen rendering would not be hw accelerated.