我想使用一个名为 libCinder 的 grate lib,我查看了 其文档 但不知道是否可能以及如何渲染某些内容而不先显示它?
假设我们要创建一个简单的随机颜色 640x480 画布,上面有 3 个红白蓝圆圈,并从其中获取 RGB\HSL\any char *
原始图像数据,而不显示任何窗口用户。 (假设我们有控制台应用程序项目类型)。我想使用这样的功能来生成服务器端实时视频流,对于视频流,我更愿意使用 ffmpeg 所以这是为什么我想要一个指向某些 RGB\HSV 或具有实际图像数据的缓冲区的指针。如何使用 libCInder 来做这样的事情?
There is that grate lib I want to use called libCinder, I looked thru its docs but do not get if it is possible and how to render something with out showing it first?
Say we want to create a simple random color 640x480 canvas with 3 red white blue circles on it, and get RGB\HSL\any char *
to raw image data out of it with out ever showing any windows to user. (say we have console application project type). I want to use such feaure for server side live video stream generation and for video streaming I would prefer to use ffmpeg so that is why I want a pointer to some RGB\HSV or what ever buffer with actuall image data. How to do such thing with libCInder?
发布评论
评论(1)
您将必须使用离屏渲染。就图形而言,
libcinder
似乎只是OpenGL
的包装器,因此您可以使用OpenGL
代码来实现这一点。由于
OpenGL
没有用于离屏渲染的本机机制,因此您必须使用扩展。可以在此处找到使用此类扩展的教程(称为“帧缓冲区渲染”)。您必须修改renderer.cpp
才能使用此扩展的命令。使用此类扩展的替代方法是使用
Mesa 3D
,它是一个开放的-OpenGL
的源实现。Mesa
有一个软件渲染引擎,可以在不使用显卡的情况下渲染到内存中。这意味着您不需要显卡,但另一方面渲染可能会很慢。Mesa
在演示zip
文件中的src/osdemos/
中有一个渲染到内存缓冲区的示例。此解决方案可能需要您编写一个完整的Renderer
类,类似于将使用Mesa
的Renderer2d
和RendererGl
的入侵,而不是Windows
或Mac
的入侵。You will have to use off-screen rendering.
libcinder
seems to be just a wrapper forOpenGL
, as far as graphics go, so you can useOpenGL
code to achieve this.Since
OpenGL
does not have a native mechanism for off-screen rendering, you'll have to use an extension. A tutorial for using such an extension, called Framebuffer Rendering, can be found here. You will have to modifyrenderer.cpp
to use this extension's commands.An alternative to using such an extension is to use
Mesa 3D
, which is an open-source implementation ofOpenGL
.Mesa
has a software rendering engine which allows it to render into memory without using a video card. This means you don't need a video card, but on the other hand the rendering might be slow.Mesa
has an example of rendering to a memory buffer atsrc/osdemos/
in the Demoszip
file. This solution will probably require you to write a completeRenderer
class, similar toRenderer2d
andRendererGl
which will useMesa
's intrusctions instead ofWindows
's orMac
's.