Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top