derpicated / articated

ARticated; An augmented reality application for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use of undeclared identifier 'GL_R8' / 'GL_RED'

idelsink opened this issue · comments

When building the android application, initialized using the following CMake arguments, I get the use of undeclared identifier 'GL_R8/GL_RED' errors.

cmake .. \
-DCMAKE_TOOLCHAIN_FILE=/home/ingmar/Android/Sdk/ndk-bundle/build/cmake/android.toolchain.cmake \
-DANDROID=ON \
-DQt5_DIR=/home/ingmar/Qt/5.10.1/android_armv7/lib/cmake/Qt5 \
-DQT_ANDROID_SDK_ROOT=/home/ingmar/Android/Sdk \
-DQT_ANDROID_ANT=/usr/bin/ant \
-DANDROID_NDK=/home/ingmar/Android/Sdk/ndk-bundle \
-DJAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b13-0.fc29.x86_64
/home/ingmar/workspace/articated/source/augmentation_widget/augmentation_widget.cpp:114:33: error: 
      use of undeclared identifier 'GL_R8'
            internalformat_gl = GL_R8;
                                ^
/home/ingmar/workspace/articated/source/augmentation_widget/augmentation_widget.cpp:115:33: error: 
      use of undeclared identifier 'GL_RED'
            format_gl         = GL_RED;
                                ^
2 errors generated.
make[2]: *** [source/augmentation_widget/CMakeFiles/augmentation.dir/build.make:79: source/augmentation_widget/CMakeFiles/augmentation.dir/augmentation_widget.cpp.o] Error 1      
make[1]: *** [CMakeFiles/Makefile2:241: source/augmentation_widget/CMakeFiles/augmentation.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

We're using GLESv3 and this should be available?

I don't understand how we are getting this issue, I'm going to have to replicate it locally to fully investigate.

As you mentioned, the OpenGL-ES 3.0 spec lists GL_R8 as a valid sized internal format, with GL_RED being the accompanying format.

When I include the QOpenGLTexture file in the augmentation_widget.cpp file. And replace GL_R8 with QOpenGLTexture::R8_UNorm and GL_RED with QOpenGLTexture::Red it all build fine. (It fails with linking but that is due to another issue, see #22)

That sounds like a hotfix, as we are not using QOpenGLTextures but rather native OpenGL texture handles, and the code should work without including it.

Yes, that is a hotfix, not the solution.

Interesting detail that can be found in the last paragraphs of this QT blogpost, it seems like QT is not always succesfull in detecting the GLES/gl3.h, the file where GL_RED is defined.
If this happens, it defaults to GLES 2.0, which does not have support for GL_RED, leading to the behaviour described in this issue.

I have implemented a preprocessor switch to include GLES/gl3.h in the case of an android build, see commit 6dc4bfb
Closing the issue