How to get OpenGL-3 headers(C/C++) in linux (with nvidia driver) - opengl

My SO is OpenSuse version 12.2 (x86_64) Mantis, with KDE desktop.
I have currently the NVidia driver (319) installed from the repository. 3D acceleration work and the driver seem to support OpenGL 4.3.
I am trying to programme a simple OpenGL sample (just a triangle in a glut windows), but I am unable because GL/gl.h is outdated: the current header is the mesa with openGL 1.3, which does nos support glCreateShader, glAttachShader...
I have tryed $ sudo find / -name gl3.h (openGL 3.1 and further should include this header) but it does not return any result, so I suppose Nvidia driver does not include library/headers.
My question is: Where can I get the GL/gl.h for the installed NVidia driver? Onyone has got this same problem and solve it?
P.S.
To install the NVidia driver, I just installed the driver from the NVidia repository for opensuse 12.2 (http://download.nvidia.com/opensuse/12.2/) (with Yast)
I have installed:
nvidia-computeG03 (NVIDIA driver for computing with GPGPU)
nvidia-gfxG03-kmp-desktop (NVIDIA graphics driver kernel module for GForce 8xxx and newer GPUs)
x11-video-nvidiaG03 (NVIDIA graphics driver for GeForce 8xxx and newer GPUx)

The correct way to access the newer features is via the GL extension mechanism. You are fine with mesa's GL.h. What you need is a current version of glext.h (which does come with the nivida drivers, iirc, but can also be found on the official opengl site). YOu then would have to query a function pointer for any function you plan to call, on your platform probably via glXGetProcAddress().
A more convenient way is to use an OpenGL loader library like glew, which will do all this for you.
Note that you could, in theory, #define GL_GLEXT_PROTOTYPES before including glext.h and directly call the functions. This is likely to work with the nvidia driver (and some others on your platform), but not guaranteed to work by any spec. And it is never going to work on other platforms, like Windows.

Related

Using Nvidia OpenCL-drivers with an ICD-loader on Windows

I have configured Installable Client Drivers (ICDs) on an Ubuntu-distribution with Intel OpenCL runtime drivers, which was fairly straightforward. These drivers come as *.so-files which can be loaded by specifying their path in an *.icd-file under /etc/OpenCL/vendors/.
How would I proceed to specify Nvidia OpenCL-drivers on Windows, and where are these drivers located?
I use MINGW64 with and OpenCL-ICD-Loader installed via MSYS2
Where is the corresponding directory to add the *.icd-files?
On Windows with MinGW-w64 I use a combination of:
https://github.com/KhronosGroup/OpenCL-Headers
https://github.com/KhronosGroup/OpenCL-ICD-Loader
OpenCL-ICD-Loader figures out where to load the Nvidia stuff from.
To build from source I had to tweak some stuff, see my build recipes:
https://github.com/brechtsanders/winlibs_recipes/blob/main/recipes/khronos-opencl-headers.winlib
https://github.com/brechtsanders/winlibs_recipes/blob/main/recipes/khronos-opencl-icd-loader.winlib

/usr/bin/ld: cannot find lGL when building Qt5 app in Qt Creator on Linux Mint

I'm porting my application from Qt4 to Qt5. I installed Qt5.2.1 from the online installer on Linux Mint 16 64-bit, in a vm on my MacBook Pro. When I run qmake and build in Qt Creator, I get:
/usr/bin/ld: cannot find -lGL
Do I need openGL? I'm not using it when I build on Windows or OSX. I'm very new to Linux, and far from expert in C++ or Qt. I found a post that included a hack to remove -lGL from mkspecs/common/linux.conf. That worked.
My question is, assuming I don't need -lGL, what is the normal way to keep the linker from attempting to link it? I imagine I do something in the .pro file, but what?
Qt5 makes heavy use of OpenGL internally. On Windows OpenGL support is a bit flaky (you must install the original vendor drivers, because Microsoft strips OpenGL from the automatically installed drivers) and hence makes use of a built in OpenGL emulation layer library.
On Linux however OpenGL support is much better. You'll find at least the Mesa softpipe backend, if the GPU is not supported by the standard drivers. If the GPU is supported, then out-of-the-box OpenGL support in Linux has become pretty good over the past years.
On MacOS X OpenGL is actually the foundation of all the higher level graphics operations and hence part of the inner workings of the operating system; sounds great in theory, but is also a major obstacle for quick version turnaround, as every major OpenGL version bump mandates an operating system update.
Now, unless your installation of Linux is seriously outdated you actually should have a OpenGL library installed. If not (and your linker error tells you this), just install the Mesa development package.
Linux Mint is a derivative of Ubuntu which in turn is a Debian derivative. The command to install the Mesa development package for OpenGL is
sudo apt-get install libgl1-mesa-dev

Getting OpenCL to work on Linux laptop with Optimus technology

I have an installation of Kubuntu 13.10 on my laptop which has an Nvidia GT555m with optimus technology. I am having some trouble getting my C++ code with OpenCL to compile.
The error I keep getting is Cannot find -lOpenCL. Doing a quick search with the GNU find utility gives me the following:
/usr/lib32/nvidia-319/libOpenCL.so.1
/usr/lib32/nvidia-319/libOpenCL.so
/usr/lib32/nvidia-319/libOpenCL.so.1.0
/usr/lib32/nvidia-319/libOpenCL.so.1.0.0
/usr/lib/x86_64-linux-gnu/libOpenCL.so
/usr/lib/nvidia-319/libOpenCL.so.1
/usr/lib/nvidia-319/libOpenCL.so
/usr/lib/nvidia-319/libOpenCL.so.1.0
/usr/lib/nvidia-319/libOpenCL.so.1.0.0
I have the following OpenCL development packages installed:
opencl-headers
nvidia-opencl-dev
I also tried the utility clinfo to see if I get any information, but I get the following error:
clinfo: error while loading shared libraries: libOpenCL.so.1: cannot open shared object file: No such file or directory
Does anyone have any experience setting up a Linux development environment with OpenCL on their optimus laptops?
I was under the impression that I do not need to do anything fancy to get this working.
EDIT: Ok it seems the reason I was not managing to compile was because I was mixing up headers and libraries. Using the following compiles my code well:
g++ -std=c++11 -I /usr/local/cuda-5.5/include vadd.cpp -L /usr/lib/nvidia-331 -lOpenCL
I am getting another error during runtime now (but at least I managed to compile!). The error is as follows:
ERROR: clGetPlatformIDs
-1001
From doing some research this means I probably do not have the ICD portion of nvidias toolkit installed? What I cannot understand is - where to find it!
You should install the Nvidia Cuda SDK. It contains OpenCL development libraries and includes.
You don't need development packages or libraries, (OpenCL is already there, and working, just giving you a runtime error, ICD is present). What you need is a platform ready to execute the OpenCL code, so a GPU + a driver.
You need to install the propietary driver of nVIDIA: Either by using the Ubuntu tools, or by installing the package nvidia-current.
Maybe you have to install bublebee. A library to use Cuda on Nvidia cards with optimus technology.
I do not use Kubuntu yet I got it working under Mageia release 6 Linux so I guess it should be pretty similar. In my case there were Intel and Nvidia (GeForce GTX 980M) graphic cards together in my laptop. My intention was to get running only OpenCL compiled code without any set up of Xorg graphical server.
So, as advised above by DarkZeros I did it by using only a proprietary nvidia driver (in my case downloaded from Nvidia page). Then under root user:
./NVIDIA-Linux-x86_64-375.39.run --no-opengl-files
It asked me if I wanted to modify my Xorg configuration - I said "NO". This delivered nvidia kernel modules. Next, I modified /etc/modules to let the Linux know that it should load them at start up of system (this might be different on Kubuntu)
[root#localhost ~]# cat /etc/modules
nvidia
nvidia-uvm
nvidia-drm
nvidia-modeset
and that was really it. Reboot your system and loading of modules should automatically also create correct nvidia device files under a /dev directory.
[root#localhost ~]# ls /dev/nvidia*
/dev/nvidia0 /dev/nvidiactl /dev/nvidia-uvm /dev/nvidia-uvm-tools
I've got an inspiration from [ftp://download.nvidia.com/XFree86/Linux-x86/295.59/README/optimus.html][1]

Open GL version 2.1 instead of 3.2 on OS X 10.8

I have a late 2009 Macbook http://support.apple.com/kb/SP579
I upgraded the operating system everytime a new one came out, so I'm using 10.8 Mountain Lion now. I was trying to get a program to work when the developer suggested I check my Open GL version with glxinfo.
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce 9400M OpenGL Engine
OpenGL version string: 2.1 NVIDIA-8.12.47 310.40.00.05f01
OpenGL shading language version string: 1.20
OpenGL extensions:
According to this https://developer.apple.com/graphicsimaging/opengl/capabilities/
I should have Open GL version 3.2, but I don't. I've also looked for newer Nvidia drivers, but the nvidia drivers download website doesn't show any for OS X 10.8 (Mountain Lion), GeForce 9400M. The Open GL website says that unlike other operating systems, Open GL is updated along with the other OS X updates.
What do? How do I get OpenGL to 3.2?
I check my Open GL version with glxinfo
glxinfo goes through the X11 server. The OpenGL support of the X11 server which is shipping with OS X is rather limited. You must check with a tool that queries the native OpenGL API of OS X, not the GLX emulation layer.

How to use current version of opengl in cygwin?

I have been using OpenGL with cygwin for a few months to program some 3d applications. I now want to attempt to write some slightly more advanced techniques using things like vertex buffer objects. However, I noticed that I ran into an obstacle: when I use glGetString(GL_VERSION) in my program it spits out 1.4.
I compile my program with these flags: -lGL -lglut -lGLU -lGLEW and have included these headers: freeglut.h glew.h. I have chosen to link against the X11 libraries vs. the windows ones as explained here. My current OpenGL programs build and are able to run (because up until now, I have used older functionality--pre-OpenGL 1.4).
I have a new desktop computer with an ATI FirePro V4800 (FireGL) graphics card that can support up to OpenGL 4.1. I have installed the latest drivers and it passes the tests supplied by the program: OpenGL Extensions Viewer. In addition, the program shows that all the extensions up to and including 4.1 are available for my graphics card.
There is a brief mention here under the last answer saying that cygwin may want to use older dlls (ones that don't support shaders, etc.). Is this a cygwin problem? Will cygwin just not recognize my latest drivers and offer me the cool stuff in OpenGL 4.1? Or am I not linking to the correct libraries?
UPDATE
After getting to know how Cygwin's X Server works I figured I should switch to freeglut's native windows libraries. I grabbed the pre-compiled binaries found here and put the files in appropriate directories to link against them. After recompiling I am able to use all the options found in OpenGL as my graphics card permits (4.1).
When using Cygwin's X-server, start it with -wgl option (current versions do that automatically) then
export LIBGL_USE_WGL=1
On the machine I'm posting from, I get:
$ glxinfo | grep OpenGL
OpenGL vendor string: Intel
OpenGL renderer string: Intel(R) HD Graphics 2500
OpenGL version string: 4.0.0 - Build 9.17.10.3062
OpenGL shading language version string: 4.00 - Build 9.17.10.3062
[...]
Unsetting the environment variable:
$ glxinfo | grep OpenGL
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 3.4, 256 bits)
OpenGL version string: 3.0 Mesa 10.3.5
OpenGL shading language version string: 1.30
[...]