Simple_GLSL_Shader_Example
Simple_GLSL_Shader_Example copied to clipboard
Mac compilation error
Hey Maurice, thanks for sharing this cool project! I saw you had only tested this on Debian systems; I went and tried to compile on my Mac and got the following error output:
./types.h:8:10: fatal error: 'GL/gl.h' file not found
#include <GL/gl.h>
^
1 error generated.
stringOutput.c:11:10: fatal error: 'GL/glut.h' file not found
#include <GL/glut.h>
^
1 error generated.
In file included from imageLoader.c:7:
./imageLoader.h:19:10: fatal error: 'GL/glu.h' file not found
#include <GL/glu.h>
^
1 error generated.
main.c:15:10: fatal error: 'GL/glut.h' file not found
#include <GL/glut.h>
^
1 error generated.
scene.c:19:10: fatal error: 'GL/glut.h' file not found
#include <GL/glut.h>
^
1 error generated.
io.c:11:10: fatal error: 'GL/glut.h' file not found
#include <GL/glut.h>
^
1 error generated.
logic.c:17:10: fatal error: 'GL/glut.h' file not found
#include <GL/glut.h>
^
1 error generated.
linking source object and image loader object files . . .
clang: error: no such file or directory: 'vector.o'
clang: error: no such file or directory: 'imageLoader.o'
clang: error: no such file or directory: 'main.o'
clang: error: no such file or directory: 'scene.o'
clang: error: no such file or directory: 'io.o'
clang: error: no such file or directory: 'logic.o'
clang: error: no such file or directory: 'stringOutput.o'
Just thought I'd let you know!
The includes are slightly different for osx. Try changing to them to the following instead;
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
I generally tend to add the following to my code instead, in order to avoid that.
#ifdef __APPLE__
# include <OpenGL/gl.h>
# include <OpenGL/glu.h>
# include <GLUT/glut.h>
#else
# include <GL/gl.h>
# include <GL/glu.h>
# include <GL/freeglut.h>
#endif
@pgunasekara Hmm, I tried that, but it looks like I get the same errors as before whenever I run ./compile.sh
@narner also add -framework OpenGL -framework GLUT
to the link link in compile.sh and remove the linux eqivalents -lglut -lGLU -lGL
I got it to compile and run, but got a bunch of other runtime errors that I resolved with this post http://stackoverflow.com/questions/20931528/shader-cant-be-compiled but I just get a large empty window.
Looks like the shaders are not compiled correctly? Could be because of the legacy profile which just goes for OpenGL/GLSL 2.1... I have actuall no idea how to get to OpenGL 3.3...
Yea, here's the output on my mac -
ajay@ajays-MacBook-Pro 12:37 [164]$ ./shaderDemo
--> Load shaders...
Compiling Vertex shader
vertexShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:3: 'layout' : syntax error: syntax error
Compiling Fragment shader
fragmentShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
programErrorMessage: ERROR: One or more attached shaders not successfully compiled
Compiling Vertex shader
vertexShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:3: 'layout' : syntax error: syntax error
Compiling Fragment shader
fragmentShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
programErrorMessage: ERROR: One or more attached shaders not successfully compiled
Compiling Vertex shader
vertexShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:3: 'layout' : syntax error: syntax error
Compiling Fragment shader
fragmentShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
programErrorMessage: ERROR: One or more attached shaders not successfully compiled
Compiling Vertex shader
vertexShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
ERROR: 0:3: 'layout' : syntax error: syntax error
Compiling Fragment shader
fragmentShaderErrorMessage: ERROR: 0:1: '' : version '330' is not supported
programErrorMessage: ERROR: One or more attached shaders not successfully compiled
--> Shaders are loaded.
Width of sunset-red.bmp: 1023
Height of sunset-red.bmp: 1024
--> Finished Initialization.
OK, so OpenGL 3.3 is not supported by your core profile. It might be possible to switch to the legacy one. But I have no idea how. And in my experience that will take some time with no guarantee for success...
If someone gets it to work in Mac, please let me know.