将OpenGL库添加到软件包中
我开发了一个科学代码包(用于碰撞/引力 N 体模拟)。它不需要任何库即可运行。人们可以下载它并只需输入 make 即可编译它。我想保持这么简单。
我添加了 OpenGL 作为实时可视化模拟的选项。看起来真的很棒。然而,有些人的机器上没有安装 OpenGL/GLUT 库。
允许这些用户使用我的代码而无需手动安装外部库的最简单方法是什么?我有一种感觉,如果我写一句“请安装 OpenGL/GLUT”。在手册中,它会让很多人望而却步。我可以将 freeglut 添加到我的源代码包中吗?这是个好主意吗?或者您还有其他建议吗?
I have developed a scientific code package (for collisional/gravitational N-body simulations). It does not require any libraries to run. People can download it and simply type make to compile it. I want to keep it that simple.
I added OpenGL as an option to visualize the simulation in real time. It looks really great. However, some people don't have an OpenGL/GLUT library installed on their machine.
What is the easiest way to allow those users to use my code without having to install external libraries manually. I have the feeling that if I write a sentence like "Please install OpenGL/GLUT." in the manual, it will put off many people. Can I just add freeglut to my source package? Is that a good idea, or do you have any other suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管名称如此,OpenGL 并不是真正的库。我建议将 OpenGL 的 L 理解为“Layer”。 OpenGL 作为 GPU 驱动程序的一部分。在这种情况下,系统上安装的动态库为驱动程序提供 API,但几乎没有内部功能。因此,在程序中附带 OpenGL“库”是没有意义的。
您只需使其依赖于 opengl32.dll/libGL.so/OpenGLFramework 即可。如果使用 OpenGL 是可选的,则可以动态加载 API 访问库,但这相当混乱。
OpenGL is not really a library, despite the name. I suggest reading the L of OpenGL as "Layer". OpenGL comes as part of the GPUs drivers. In that case the dynamic library installed on the system provides an API to the drivers, but next to no internal functionality. So there it makes no sense shipping an OpenGL "library" with your program.
You just make it dependent on opengl32.dll/libGL.so/OpenGLFramework. If use of OpenGL is optional, there is the possibility to load the API access library dynamically, but this is quite a mess.
OpenGL 通常随显卡驱动程序一起提供,因此只要最终用户拥有正确的驱动程序,他们就已经安装了库。但这取决于他们运行的平台。
Windows 自 Windows 95 起就包含了一个开箱即用的 OpenGL 实现。我相信它是一个软件渲染后备(尽管较新的可能是 DirectX 包装器),并且它是一个相当旧的 OpenGL 版本 (1.1),因为它早于他们自己试图通过Direct3D。当然,大多数较新的功能在软件中无法正常工作,因为它们类似于需要专门硬件的着色器。这实际上取决于您的程序的图形密集程度。
Mac OS 自 OS9 以来就有官方支持 OpenGL(不同的 OpenGL 版本取决于操作系统版本),OSX 10.7 有 OpenGL 3.2,但似乎 1.1->2.1 可能取决于硬件/OSX 版本)。
大多数现代桌面 Linux 实现都会有一些 OpenGL 支持,可能通过专有的官方 ATI/nVidia/Intel 驱动程序。还有一些开源驱动程序,例如 Nouveau 。不幸的是,还有许多平台的实现有问题,没有免费软件实现(一些发行版/最终用户拒绝使用封闭组件),或者没有加速。例如,Intel GMA500 芯片组目前已相当损坏。
如果您仍然想包含后备,请尝试查看 Mesa。它是一个开源跨平台软件渲染 OpenGL 实现。您可能可以将其包括在内。它支持 OpenGL 2.1 版本,并且正在开发 3.0+ 版本,其中一些扩展已经可用。像着色器这样的东西会很慢(有一个名为 LLVMpipe 的项目可能会提供改进,但它相当经验性,而且只能做这么多)。
还有 ANGLE 项目,它是 OpenGL ES 2.0 DirectX 9.0 包装器。我相信它来自 Google,旨在支持 Windows 上的 Chrome/Chromium 的 WebGL。但它当然是 OpenGL ES,现在是完整的 OpenGL,并且只会在 Windows 上为您提供帮助。
最好的选择可能是禁用 OpenGL 模拟选项,除非安装了库。
OpenGL is normally shipped with graphics card drivers so provided the end users have correct drivers they will have the libs installed already. But it will depend on what platform they are running.
Windows includes an OpenGL implementation out of the box since Windows 95. I believe its a software rending fallback (although newer ones might be DirectX wrappers) and it's a fairly old OpenGL version (1.1) since it predates their own attempt to dominate the market via Direct3D. Of course most newer features won't work well in software since they are things like shaders that require specialized hardware. It will really depend on how graphics intensive your program is.
Mac OS has official support or OpenGL since OS9 (various OpenGL versions depending on the OS version), OSX 10.7 has OpenGL 3.2 but it seems 1.1->2.1 is likely depending on what hardware/OSX version).
Most modern desktop Linux implementations will have some OpenGL support, possibly via the proprietary official ATI/nVidia/Intel drivers. There are also some opensource drivers like Nouveau . Unfortunately there are also many platforms with broken implementations, no freesofware implementations (some distro/endusers refuse to use closed components), or no acceleration. For example the Intel GMA500 chipset is currently fairly broken.
If you still want to include a fallback try looking at Mesa. It is an opensource cross platform software rendering OpenGL implementation. It is possible that you might be able to include that. It supports OpenGL versions 2.1 and they are working on 3.0+ with some extensions already available. Things like shaders will be slow (there is a project called LLVMpipe that might offer improvements but it's fairly experiential and it's only going to be able to do so much).
There's also the ANGLE project which is an OpenGL ES 2.0 DirectX 9.0 wrapper. I believe it's from Google with an intent to support Chrome/Chromium's WebGL on Windows. But it is of course OpenGL ES now the full OpenGL and will only help you with Windows.
Chances are your best option is to just disable the OpenGL simulation option unless they have the libs installed.