OpenGL glGetUniformLocation cannot be resolved - c++

I am developing a project using OpenGL and I need to use shaders. I have an example project which was given to me but I am struggling to compile it - I get the error: Function glGetUniformLocation cannot be resolved.
I am using Ubuntu 14.04, and the images below show my current graphics driver and OpenGL version as well as a screenshot of eclipse where you can see the problems list and, as I believe, the prototype of the function in glew.h which is included by the project.

Related

Qt 5.12 D3D compiler module not found

I've installed Qt 5.12 , When i want to compile my project show this
errors:
Errors :
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
ensureInitialized(141): D3D compiler module not found.
QOpenGLShader::link: D3D compiler module not found.
shader compilation failed:
"D3D compiler module not found.\n"
Welcome to SO!
First of all, let's clarify what the error means.
Qt uses ANGLE on Windows, which is a layer that allows to run OpenGL software on systems where OpenGL is not available, by traslanting the OpenGL calls into DirectX calls. Qt decides whether to go with pure OpenGL or ANGLE depending on the configuration of the machine (video card model, video drivers version, etc).
More details on that are available at https://wiki.qt.io/Qt_5_on_Windows_ANGLE_and_OpenGL.
Even if you are not writing any OpenGL code yourself, the qml runtime surely has a lot of OpenGL calls that again, may go through ANGLE.
That is why the confusing error message (looking for the D3D shader compiler while dealing with OpenGL code!).
Now, the Qt project bugtracker reports the same issue you have https://bugreports.qt.io/browse/QTBUG-71510, although at the time of writing no solution has been provided. I would suggest to have a look at the bugtracker now and then to monitor the progress on this issue.
A couple of workarounds you may try:
Copy the d3dcompiler_xx.dll in the same directory where your exe is;
Force Qt to use OpenGL instead of DirectX, by setting the environment variable QT_OPENGL to desktop (more details on that are at http://doc.qt.io/qt-5/windows-requirements.html)
According to bugreports.qt this issue is now fixed from version QT 5.12.1.
https://bugreports.qt.io/browse/QTBUG-71510
I have the same issue on my older Del laptop. Placing d3dcompiler_43.dll in the exe folder does solve the issue. I found using one of the following commands also works, which I assume avoids ANGLE all together.
//To use pure OpenGL :
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
//Or use software emulated OpenGL :
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
I just include the first pure OpenGL setting in the "int main(int argc, char *argv[])" bracket in main.cpp

By using QOpenGLContext and OpenGLVertexBufferObject, rendering looks missed depth

My platform information: Qt 5.4.1, ubuntu 14.04, windows 8.1
I have made QOpenGLWindow based on QWindow. To make it OpenGLWindow, I used QOpenGLContext and made OpenGL context for each of them. In QOpenGLWindow, to render object I used VertexBufferObject of native OpenGL. and I passed vertices, normals to buffer object and rendered it. here is my two situation of this application. first one worked on ubuntu 14.04, second one worked on windows 8.1.
I have got first one because I develop application mainly on ubuntu 14.04. It seems that it doesn't know depth when it is rendered. and it looks transparent for all front faces. I had hard time to figure out problem so I tested it on windows 8.1 with same version of Qt which is Qt 5.4.1. It works fine as you can see second picture.
So I'm thinking about Qt's issue for different platform. I had similar issue before(it was fixed to Qt 5.5): https://bugreports.qt.io/browse/QTBUG-45037
is there anyone with similar problem?

Setting up a dev environment for OpenGL 4.2 on Linux (trouble sourcing gl.h)

I'm using GLFW and Netbeans to develop in C++. I'm able to render with immediate mode functions no problem. However, when I try to use core profile functions I get errors like this:
error: ‘glCreateShader’ was not declared in this scope
I get one of these errors for each core profile function I try. I did some research and found that GLFW doesn't provide any gl headers and just #includes the headers found on my system (at /usr/include/GL/).
Presumably this means that the gl.h and related files found here only contain the old style OpenGL API. I can't make sense of the hex code, but the gl.h file #defines GL_VERSION as 0x1F02.
If I perform this command in terminal: glxinfo | grep -i opengl it assures me that my OpenGL version string is "4.2.0 NVIDIA 304.88" -- Although I think that's reflected in the driver, unrelated to the gl.h file. Running this line in C++ code in my application yields the same string: printf("%s\n", glGetString(GL_VERSION)); For the same reason, no doubt.
Where can I source the appropriate OpenGL header files for OpenGL 3+ development on Ubuntu 13.04 x64?
I have installed these packages as suggested by most tutorials (to no avail): xorg-dev libglu1-mesa-dev
glCreateShader (...) is an OpenGL 2.0 function.
Short of OS X, I cannot think of any platforms that ship with OpenGL 2.0 without requiring runtime extension. On Microsoft Windows, you are guaranteed the full feature set of OpenGL 1.1 and anything beyond that requires calls to wglGetProcAddress (...) to load the function entry-points for the rest of the OpenGL API. The situation is the same on Linux, though it is more difficult to define what the "minimum" feature set is. In any case, to use glCreateShader (...) you are going to have to call glXGetProcAddress (...) in order to get the entry-point from the driver.
Libraries like GLEW will make your life easier by loading the entry-point for every function for each extension and core version of OpenGL your driver supports, on Ubuntu there should even be a package you can install that contains GLEW. Nevertheless, see the official project site for more details on actually using GLEW.

Missing openGL texture flag GL_TEXTURE_RECTANGLE

I queried my opengl version using glGetString(GL_VERSION) and it returned 3.3.0. As far as I know, 3.3 does have the GL_TEXTURE_RECTANGLE flag. However I'm unable to find it in my gl.h header nor does my compiler(VC++) recognize the flag. All my other openGL calls seem to run fine. Any ideas?
Unfortunately, Visual Studio does not ship with up-to-date OpenGL support. Check out GLEW for a solution to this problem.

How do i link SDL and GL in monodevelop (C++)

I am trying compile a simple program using openGL and SDL but I can't seem to link the library in monodevelop
I tried following This guide but neither SDL nor GL are on the packages list
You need to download the Tao Framework and add the SDL and OpenGL dlls to the project references.
See here for more details.