dalerank / nanogui-sdl

Minimalistic port of NanoGUI claim works with SDL API w/o external dependencies.
Other
437 stars 77 forks source link

Failing to compile on MacOS X #25

Closed dorier closed 5 years ago

dorier commented 6 years ago

Any chance you could document how to build on Mac OSX? I'm on High Sierra, I have installed SDL and SDL2 with Homebrew (apparently both are needed), but I have errors when building:

Scanning dependencies of target nanogui
[  7%] Building CXX object CMakeFiles/nanogui.dir/src/darwin.mm.o
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:24:8: error: unknown type name 'PFNGLUNIFORM1IPROC'; did you mean 'PFNGLUNIFORM1IARBPROC'?
extern PFNGLUNIFORM1IPROC glUniform1i ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM1IARBPROC
/usr/local/include/SDL/SDL_opengl.h:4151:25: note: 'PFNGLUNIFORM1IARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:24:27: error: redefinition of 'glUniform1i' as different kind of symbol
extern PFNGLUNIFORM1IPROC glUniform1i ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2935:13: note: previous definition is here
extern void glUniform1i (GLint location, GLint v0);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:25:8: error: unknown type name 'PFNGLUNIFORM1FPROC'; did you mean 'PFNGLUNIFORM1FARBPROC'?
extern PFNGLUNIFORM1FPROC glUniform1f ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM1FARBPROC
/usr/local/include/SDL/SDL_opengl.h:4147:25: note: 'PFNGLUNIFORM1FARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:25:27: error: redefinition of 'glUniform1f' as different kind of symbol
extern PFNGLUNIFORM1FPROC glUniform1f ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2931:13: note: previous definition is here
extern void glUniform1f (GLint location, GLfloat v0);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:26:8: error: unknown type name 'PFNGLUNIFORM2IPROC'; did you mean 'PFNGLUNIFORM2IARBPROC'?
extern PFNGLUNIFORM2IPROC glUniform2i ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM2IARBPROC
/usr/local/include/SDL/SDL_opengl.h:4152:25: note: 'PFNGLUNIFORM2IARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:26:27: error: redefinition of 'glUniform2i' as different kind of symbol
extern PFNGLUNIFORM2IPROC glUniform2i ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2936:13: note: previous definition is here
extern void glUniform2i (GLint location, GLint v0, GLint v1);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:27:8: error: unknown type name 'PFNGLUNIFORM2FPROC'; did you mean 'PFNGLUNIFORM2FARBPROC'?
extern PFNGLUNIFORM2FPROC glUniform2f ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM2FARBPROC
/usr/local/include/SDL/SDL_opengl.h:4148:25: note: 'PFNGLUNIFORM2FARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:27:27: error: redefinition of 'glUniform2f' as different kind of symbol
extern PFNGLUNIFORM2FPROC glUniform2f ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2932:13: note: previous definition is here
extern void glUniform2f (GLint location, GLfloat v0, GLfloat v1);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:28:8: error: unknown type name 'PFNGLUNIFORM3FPROC'; did you mean 'PFNGLUNIFORM3FARBPROC'?
extern PFNGLUNIFORM3FPROC glUniform3f ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM3FARBPROC
/usr/local/include/SDL/SDL_opengl.h:4149:25: note: 'PFNGLUNIFORM3FARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:28:27: error: redefinition of 'glUniform3f' as different kind of symbol
extern PFNGLUNIFORM3FPROC glUniform3f ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2933:13: note: previous definition is here
extern void glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:29:8: error: unknown type name 'PFNGLUNIFORM3IPROC'; did you mean 'PFNGLUNIFORM3IARBPROC'?
extern PFNGLUNIFORM3IPROC glUniform3i ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM3IARBPROC
/usr/local/include/SDL/SDL_opengl.h:4153:25: note: 'PFNGLUNIFORM3IARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:29:27: error: redefinition of 'glUniform3i' as different kind of symbol
extern PFNGLUNIFORM3IPROC glUniform3i ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2937:13: note: previous definition is here
extern void glUniform3i (GLint location, GLint v0, GLint v1, GLint v2);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:30:8: error: unknown type name 'PFNGLUNIFORM4FPROC'; did you mean 'PFNGLUNIFORM4FARBPROC'?
extern PFNGLUNIFORM4FPROC glUniform4f ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM4FARBPROC
/usr/local/include/SDL/SDL_opengl.h:4150:25: note: 'PFNGLUNIFORM4FARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:30:27: error: redefinition of 'glUniform4f' as different kind of symbol
extern PFNGLUNIFORM4FPROC glUniform4f ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2934:13: note: previous definition is here
extern void glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:31:8: error: unknown type name 'PFNGLUNIFORM4IPROC'; did you mean 'PFNGLUNIFORM4IARBPROC'?
extern PFNGLUNIFORM4IPROC glUniform4i ;
       ^~~~~~~~~~~~~~~~~~
       PFNGLUNIFORM4IARBPROC
/usr/local/include/SDL/SDL_opengl.h:4154:25: note: 'PFNGLUNIFORM4IARBPROC' declared here
typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
                        ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:31:27: error: redefinition of 'glUniform4i' as different kind of symbol
extern PFNGLUNIFORM4IPROC glUniform4i ;
                          ^
/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2938:13: note: previous definition is here
extern void glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
            ^
In file included from /Users/mdorier/nanogui-sdl/src/darwin.mm:1:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/nanogui.h:33:
In file included from /Users/mdorier/nanogui-sdl/include/nanogui/imageview.h:18:
/Users/mdorier/nanogui-sdl/include/nanogui/glutil.h:48:66: error: use of undeclared identifier 'GL_HALF_FLOAT'
template <> struct type_traits<half_float::half> { enum { type = GL_HALF_FLOAT, integral = 0 }; };
                                                                 ^
17 errors generated.
make[2]: *** [CMakeFiles/nanogui.dir/src/darwin.mm.o] Error 1
make[1]: *** [CMakeFiles/nanogui.dir/all] Error 2
make: *** [all] Error 2

I'm guessing those errors are related to OpenGL's installation on OSX?

dorier commented 6 years ago

I managed to have NanoGUI-SDL compile by removing the condition that NANOGUI_LINUX must be defined to use SDL2/SDL_opengl.h in the following:

#ifdef NANOGUI_LINUX
    #include <SDL2/SDL_opengl.h>
    #include <SDL2/SDL_opengl_glext.h>
#else
    #include <SDL/SDL_opengl.h>
#endif

(in opengl.h and in the examples) I also had to add SDL2 as external library line 102 of the CMakeLists.txt file.

Now I have another issue; when I run either of the example programs, I get the following output:

Available Renderers: opengl metal software Vendor : Intel Inc. Renderer : Intel(R) HD Graphics 6000 Version : 4.1 INTEL-10.32.48 Shader shader/vert error: ERROR: 0:1: '' : #version required and missing. ERROR: 0:13: 'attribute' : syntax error: syntax error

libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Could not initialize NanoVG! Abort trap: 6

dorier commented 6 years ago

Making progress: adding -DNANOGUI_GL_IMPLEMENTATION=gl3 in the cmake command makes everything works fine.

Would be worth documenting all of this :-)

dalerank commented 5 years ago

library redesinged for sdl2 api, try now