有没有某种方法可以以独立于语言的方式表达 OpenGL 指令?
标题几乎说明了这一点。我正在考虑制作一个简单的视频编辑器,但我不确定各种效果和滤镜等的“逻辑”。假设我想让外部程序能够对图像应用一些效果。它是否必须是一个执行的程序,或者它可以只是视频编辑器可以解析的一组 OpenGL 指令,并且本质上“传递”给 OpenGL。从技术上讲,这将是一个程序,但它似乎比仅仅为了应用效果而制作一个成熟的辅助程序更优雅和标准化。也许有更好的方法?
编辑:谢谢你们的回答。不过,这是后续内容:其他视频编辑器如何实现这一点?我之所以问这个问题,是因为对于上述问题,答案似乎相当否定,所以我想知道专业应用程序是如何完成的。
The title pretty much says it. I was thinking about making a simple video editor, and I was unsure about the "logistics" of various effects and filters and such. Let's say I want to make it possible for an external program to apply some effect to the image. Does it have to be an executed program necessarily, or can it simply be a set of OpenGL instructions that the video editor can parse, and essentially "pass along" to OpenGL. Technically, that would be a program, but it seems more elegant and standardized than making a full fledged secondary program just to apply an effect. Maybe there's a better way?
Edit: Thanks for the answers guys. Here's a follow up though: How do other video editors implement this? The reason I ask is because the answers seem to be rather negative on the above point, so I was wondering how it is done by professional applications.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
有多种方法可以解决该问题(“使视频编辑器能够创建自定义效果”)。
除此之外,没有“独立于语言”的方式来产生效果。您要么必须使用现有的语言来使效果插件与您的应用程序交互,要么您必须创建自己的“语言”来描述效果。处理这个问题的唯一与语言无关的方法是雇用一名程序员并告诉他你想要什么样的效果。但话又说回来,这需要自然语言。
There are several ways to approach the problem ("make video editor with ability to create custom effects").
Aside from that, there is no "language-independent" way to make effect. Either you have to use existing language to make effect plugin interact with your application, OR you have to make your own "language" to describe effect. The only language-independent way to deal with this is to hire a programmer and tell him what kind of effect you want. But then again, that requires natural language.
任何事情都有效。然而,在 OpenGL 标准本身中,并没有“OpenGL 指令”或“操作码”之类的东西。但至少在具有间接 GLX 的基于 X11 的系统中这是可能的,因为 GLX 实际上定义了操作码。如果是间接的,多个 X 客户端可以在同一上下文上操作。不幸的是,大多数时候您不会有这个选项,因为您可能需要直接上下文,因为您可能需要 OpenGL3(并非所有操作都有操作码定义,这使得 OpenGL-3 无法进行间接操作),或者因为您'我不使用 GLX。
因此,下一个选项是为其他进程提供某种 OpenGL 命令/解释器提示。如果您很懒,我建议您在程序中嵌入一个 Python 解释器以及 Python OpenGL 绑定。它们在当前活动的任何上下文上运行,允许其他程序实际发送一些 Python 脚本来完成它的工作。
最后但并非最不重要的一点是,您可以通过某些 RPC 接口提供 OpenGL。
或者你提供一些插件系统,在其中加载一些 DLL,从而完成该任务。
Either thing works. However in the OpenGL standard itself there's no such thing like "OpenGL instructions" or "opcodes". But at least in X11 based systems with indirect GLX this is possible, because GLX actually defines opcodes. And it is possible for multiple X clients to operate on the same context if it is indirect. Unfortunately you won't have that option most of the time, as you probably want a direct context, because you may want OpenGL3 (for which not all operations have opcodes defines, which makes indirect impossible for OpenGL-3), or because you're not using GLX.
So the next option is, that you provide the other process with some kind of command/interpreter prompt for OpenGL. If you're lazy I suggest you just embedd a Python interpreter in your program, together with the Python OpenGL bindings. Those operate on whatever context that's currently active, allowing the other program to actually send some Python script to do its stuff.
And last but not least you could provide OpenGL through some RPC interface.
Or you provide some plugin system, where you load some DLL, which does the deed.
当然可以,但这基本上相当于你创建自己的语言。您可以通过某些文本界面接受来自用户的 OpenGL“指令”(或者如果您想以某种方式将某些内容组合在一起作为 GUI),然后解析这些“指令”,底层实现将以您的应用程序使用的任何语言执行这些指令写在.
Sure, but it would be basically the equivalent of you creating your own language. You can accept OpenGL "instructions" from the user via some text interface (or if you want to somehow put something together as a GUI), then parse those "instructions", and the underlying implementation would execute those instructions in whatever language your application is written in.
简短的回答是否定的。您正在寻找的是 HCI 人员梦想的 DSL,无论底层技术如何,它都可以描述演示。
The short answer is no. What you are looking for is a HCI guy's dream DSL which would describe presentation regardless of the underlying technology.
可能不完全是你想要的,你可能想看看 GLSL。 GLSL是一种类C语言,由图形卡驱动程序编译为本机“图形汇编语言”。
Probably not quite what you wanted, you might want to look at GLSL. GLSL is a C-like language that is compiled by the graphic card driver into native "graphic assembly language".