fogleman/Craft

OpenGL 3.30 not supported by craft

crazyBaboon opened this issue · 11 comments

I have tried everything
but when I attempt to use opengl 3.3 I get:

glCompileShader failed:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

It's not OpenGL 3.3 not supported by craft, actually, the build does not support GSLS 330, and if you built it yourself, it means your computer does not support OpenGL 3.3

Do you mean OpenGL 3.30 is supported by Craft?

By looking at the code, it's not hinting glfw the opengl version, so it should support any opengl version ¯\(ツ)
It looks like a shader bug (all the shaders are written for GLSL 120, not 330), kinda strange

@crazyBaboon FYI, static shadows where already implemented in the shadow branch, probaly following the tutorial you linked or something similar.

I think you're probably missing to define GLFW_INCLUDE_GLCOREARB:

#define GLFW_INCLUDE_GLCOREARB
#include <GLFW/glfw3.h>

like Fogleman did in his branch shadow/main.c#L1

Also, if you are a MacOS user you still may have to explicity use in you code:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

If after all of this you still get the error it might be you have an old OpenGL version.

I think I got the same error as yours when trying to run a GLSL 3.30 shader with OpenGL 3.0 (which supports up to GLSL 1.30):

GL version                     GLSL version
2.0                            1.10
2.1                            1.20
3.0                            1.30
3.1                            1.40
3.2                            1.50
3.3                            3.30
4.0                            4.00
4.1                            4.10
4.2                            4.20
4.3                            4.30
4.4                            4.40
4.5                            4.50

If you're interested here's a sample from the shadow branch:

shadows1

shadows2

@mpaoloni

Wow! I did not know that! Thanks!

How do I change the following:

git clone https://github.com/fogleman/Craft.git
cmake .
make
./craft

in order to compile the shadows branch?

For the sake of simplicity I would suggest cloning that single branch only (not the whole repository), like this:

git clone --single-branch -b shadow https://github.com/fogleman/Craft.git

then proceed like usual:

cd Craft
cmake .
make
./craft

IIRC on Linux i had some errors when compiling that branch. If you have any post here the output I can try to help.

Thanks @mpaoloni ! However, when I do make I get the following error:

[  3%] Building C object glfw/src/CMakeFiles/glfw.dir/clipboard.c.o
In file included from /home/p/Documents/Craft/glfw/src/x11_platform.h:52:0,
                 from /home/p/Documents/Craft/glfw/src/internal.h:69,
                 from /home/p/Documents/Craft/glfw/src/clipboard.c:27:
/home/p/Documents/Craft/glfw/src/glx_platform.h:95:5: error: unknown type name ‘pthread_key_t’
     pthread_key_t   current;
     ^~~~~~~~~~~~~

Do you know how to fix this?

gcc 7.3

VGA compatible controller: Intel Corporation HD Graphics 520 (rev 07) (prog-if 00 [VGA controller])

glxinfo | grep OpenGL version outputs OpenGL version string: 3.0 Mesa 18.0.5

That error in particular I solved it updating the GLFW library. However at the time I also had to do other things (i.e. adding GLEW statically). I don't remember every single thing I did because I also updated the dependencies and reorganized the project structure.

I found the working copy I had, and pushed it to my cloned repo: https://github.com/mpaoloni/Craft

The changes mentioned are in the shadow branch.

To clone it, as always:

git clone --single-branch -b shadow https://github.com/mpaoloni/Craft.git

then:

cd Craft
cmake .
make
./craft

I also noticed you, like me, are running OpenGL version string: 3.0 Mesa 18.0.5. Which means once compiled and run, you'll get the error:

glCompileShader failed:
... GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, 3.00 ES, 3.10 ES, and 3.20 ES

Not sure how to resolve it (maybe switching to other drivers? not Mesa?). But since I have Windows with OpenGL 4.4 I cross-compiled it on Linux for Windows at the time.

To do this I added an option for Windows64 with cmake (inside CMakeLists.txt):

cmake -DWINDOWS=ON .

Note that to do this you'll need MinGW installed on Linux. If you have 32 bit you can change the paths inside CMakeLists.txt accordingly:

set(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc-win32")
set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++-win32")
set(CMAKE_RANLIB "/usr/bin/x86_64-w64-mingw32-ranlib")

EDIT: there was a copy/paste error in CMakeLists.txt. I fixed it now but it seemed to work anyways 3aae51d.

I just realized that: glxinfo | grep OpenGL:

OpenGL vendor string: X.Org
OpenGL renderer string: AMD TAHITI (DRM 2.50.0 / 4.15.0-36-generic, LLVM 6.0.0)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 18.0.5
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 18.0.5
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 18.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:

I have:
OpenGL core profile shading language version string: 4.50
OpenGL shading language version string: 1.30.

So maybe I can run it on Linux? Not sure how though.

Apparently with Mesa you can override the OpenGL and GLSL version with:

MESA_GL_VERSION_OVERRIDE=<version>
MESA_GLSL_VERSION_OVERRIDE=<version>

For example:

MESA_GL_VERSION_OVERRIDE=4.5 ./craft

It doesn't look quite right though...

Reference: https://askubuntu.com/questions/850900/why-is-my-opengl-version-stuck-at-3-0-despite-new-hardware-software

@mpaoloni Yep, it compiles fine on Xubuntu 18.04 using gcc 7.3.0.

But when I try to run it:

glCompileShader failed:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

glCompileShader failed:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

glLinkProgram failed: error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader
glCompileShader failed:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

glCompileShader failed:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

glLinkProgram failed: error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader
glCompileShader failed:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

glCompileShader failed:
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.00 ES, and 3.00 ES

glLinkProgram failed: error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader
Segmentation fault (core dumped)

The output to glxinfo | grep OpenGL in my Xubuntu box is:

OpenGL vendor string: Intel Open Source Technology Center
OpenGL renderer string: Mesa DRI Intel(R) Sandybridge Desktop 
OpenGL core profile version string: 3.3 (Core Profile) Mesa 18.0.5
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 18.0.5
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 18.0.5
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

Whoops. So I found the issue...

On Linux it still requires setting up the OpenGL context (commit b1d16cd):

#if defined(__APPLE__) || defined(__linux)
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
    glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#endif

Doing so, however, it would make the program crash on my Linux machine.

Until I realized I didn't update GLEW to the latest version (2.1.0), despite updating GLFW.

Now it works without any issue ^^; I pushed the changes to my shadow branch.

@mpaoloni

Thank you so much! It works amazing on GNU+Linux now!

Hopefuly @fogleman will merge your branch!