cegli / dolphin

Dolphin is a GameCube/Wii emulator, allowing you to play games for these two platforms on PC, with improvements.
GNU General Public License v2.0
5 stars 2 forks source link

OS X support? #11

Open pizthewiz opened 9 years ago

pizthewiz commented 9 years ago

A small tweak is needed to find the OVR SDK on OS X:

diff --git a/CMakeTests/FindOculusSDK.cmake b/CMakeTests/FindOculusSDK.cmake
index afd00d2..0e128f9 100644
--- a/CMakeTests/FindOculusSDK.cmake
+++ b/CMakeTests/FindOculusSDK.cmake
@@ -13,6 +13,8 @@ if (NOT OCULUSSDK_FOUND)
                /usr/include
                /usr/local/include/ovr-0.4.3/LibOVR/Include
                /usr/local/include
+               Externals/LibOVR/Include
+               Externals/
        )

        find_path(OCULUSSDK_SRC_DIR NAMES OVR_CAPI_GL.h
@@ -21,6 +23,8 @@ if (NOT OCULUSSDK_FOUND)
                /usr/include
                /usr/local/include/ovr-0.4.3/LibOVR/Src
                /usr/local/include
+               Externals/LibOVR/Src
+               Externals/
        )

        if(OCULUSSDK_INCLUDE_DIR AND OCULUSSDK_SRC_DIR)

which then results in:

-- Found Oculus SDK: /Users/pizthewiz/sandbox/rift/dolphin/Externals/LibOVR/Include, /Users/pizthewiz/sandbox/rift/dolphin/Externals/LibOVR/Src
Using Oculus SDK

But after doing so, complication of the GL bits seems to explode with unknown PFN prefixed GL types, which I think would have been defined by glext.h no?

[ 69%] Built target videosoftware
Scanning dependencies of target videoogl
[ 69%] Building CXX object Source/Core/VideoBackends/OGL/CMakeFiles/videoogl.dir/GLExtensions/GLExtensions.cpp.o
[ 69%] Building CXX object Source/Core/VideoBackends/OGL/CMakeFiles/videoogl.dir/BoundingBox.cpp.o
[ 69%] Building CXX object Source/Core/VideoBackends/OGL/CMakeFiles/videoogl.dir/FramebufferManager.cpp.o
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.cpp:14:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.h:19:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLUtil.h:8:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h:9:
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_blend_func_extended.h:7:8: error: 
      unknown type name 'PFNGLBINDFRAGDATALOCATIONINDEXEDPROC'
extern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glBindFragDataLocationIndexed;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_blend_func_extended.h:8:8: error: 
      unknown type name 'PFNGLGETFRAGDATAINDEXPROC'
extern PFNGLGETFRAGDATAINDEXPROC glGetFragDataIndex;
       ^
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.cpp:14:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.h:19:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLUtil.h:8:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h:10:
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_buffer_storage.h:7:8: error: 
      unknown type name 'PFNGLBUFFERSTORAGEPROC'
extern PFNGLBUFFERSTORAGEPROC glBufferStorage;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_buffer_storage.h:8:8: error: 
      unknown type name 'PFNGLNAMEDBUFFERSTORAGEEXTPROC'
extern PFNGLNAMEDBUFFERSTORAGEEXTPROC glNamedBufferStorageEXT;
       ^
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.cpp:14:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.h:19:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLUtil.h:8:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h:11:
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_debug_output.h:7:8: error: 
      unknown type name 'PFNGLDEBUGMESSAGECALLBACKARBPROC'
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_debug_output.h:8:8: error: 
      unknown type name 'PFNGLDEBUGMESSAGECONTROLARBPROC'
extern PFNGLDEBUGMESSAGECONTROLARBPROC glDebugMessageControlARB;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_debug_output.h:9:8: error: 
      unknown type name 'PFNGLDEBUGMESSAGEINSERTARBPROC'
extern PFNGLDEBUGMESSAGEINSERTARBPROC glDebugMessageInsertARB;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_debug_output.h:10:8: error: 
      unknown type name 'PFNGLGETDEBUGMESSAGELOGARBPROC'
extern PFNGLGETDEBUGMESSAGELOGARBPROC glGetDebugMessageLogARB;
       ^
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.cpp:14:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.h:19:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLUtil.h:8:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h:12:
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_draw_elements_base_vertex.h:7:8: error: 
      unknown type name 'PFNGLDRAWELEMENTSBASEVERTEXPROC'
extern PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_draw_elements_base_vertex.h:8:8: error: 
      unknown type name 'PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC'
extern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedB...
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_draw_elements_base_vertex.h:9:8: error: 
      unknown type name 'PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC'
extern PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glDrawRangeElementsBaseVertex;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_draw_elements_base_vertex.h:10:8: error: 
      unknown type name 'PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC'
extern PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glMultiDrawElementsBaseVertex;
       ^
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.cpp:14:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.h:19:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLUtil.h:8:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h:13:
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_ES2_compatibility.h:7:8: error: 
      unknown type name 'PFNGLCLEARDEPTHFPROC'
extern PFNGLCLEARDEPTHFPROC glClearDepthf;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_ES2_compatibility.h:8:8: error: 
      unknown type name 'PFNGLDEPTHRANGEFPROC'
extern PFNGLDEPTHRANGEFPROC glDepthRangef;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_ES2_compatibility.h:9:8: error: 
      unknown type name 'PFNGLGETSHADERPRECISIONFORMATPROC'
extern PFNGLGETSHADERPRECISIONFORMATPROC glGetShaderPrecisionFormat;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_ES2_compatibility.h:10:8: error: 
      unknown type name 'PFNGLRELEASESHADERCOMPILERPROC'
extern PFNGLRELEASESHADERCOMPILERPROC glReleaseShaderCompiler;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_ES2_compatibility.h:11:8: error: 
      unknown type name 'PFNGLSHADERBINARYPROC'
extern PFNGLSHADERBINARYPROC glShaderBinary;
       ^
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.cpp:14:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/FramebufferManager.h:19:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLUtil.h:8:
In file included from /Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/GLExtensions.h:14:
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_framebuffer_object.h:7:8: error: 
      unknown type name 'PFNGLBINDFRAMEBUFFERPROC'
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
       ^
/Users/pizthewiz/sandbox/rift/dolphin/Source/Core/VideoBackends/OGL/GLExtensions/ARB_framebuffer_object.h:8:8: error: 
      unknown type name 'PFNGLBINDRENDERBUFFERPROC'
extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [Source/Core/VideoBackends/OGL/CMakeFiles/videoogl.dir/FramebufferManager.cpp.o] Error 1
make[1]: *** [Source/Core/VideoBackends/OGL/CMakeFiles/videoogl.dir/all] Error 2
make: *** [all] Error 2
cegli commented 9 years ago

When I compile, it looks like those are being pulled from: Externals/GL/GL/glext.h.

I'm actually not very familiar with this deep of a level of the OpenGL structure. Is MacOS not supposed to use GL/GL/glext.h or is there a problem with a including it?

pizthewiz commented 9 years ago

I don't know much about GL extensions, but these PFN types are the function pointers that are seemingly not defined on OS X - I asked in #oculus on Freenode after someone else mentioned compiling Dolphin on Linux, and it was suggested we use an extension wrapper like GLEW or GLee.

When the OVR SDK isn't found, the compile goes without a hitch (but dies linking on a missing OVR static lib), so I'm also guessing the errors come out some code for the Rift additions?

feilen commented 9 years ago

That tweak you made to FindOculus.cmake is actually necessary for general development on anything but Arch linux, so probably best to include it.

I think every operating system (Android, Windows, Linux, Mac) use a different GL extension, and they have to be tweaked individually to support them. It's probably an issue with missing implementation in whatever GL backend mac uses. (Windows uses WGL, Linux uses GLX, what does Mac use?) I'll see what I can do about supporting it but I don't really have anywhere to test.

pizthewiz commented 9 years ago

@feilen I'm taking a look at this again and I think OS X uses AGL in Dolphin. I had to tweak FramebufferManager.cpp on OS X and tweak AGL.h and AGL.cpp to add offscreen variant methods, but it is still blows up on the unknown types. Does Linux use glext.h and Windows uses wglext.h?

diff --git a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
index eb97dc5..c94596e 100644
--- a/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
+++ b/Source/Core/VideoBackends/OGL/FramebufferManager.cpp
@@ -6,6 +6,8 @@
 #include "VideoBackends/OGL/GLInterface/WGL.h"

 #include "VideoCommon/VR920.h"
+#elif defined(__APPLE__)
+#include "VideoBackends/OGL/GLInterface/AGL.h"
 #else
 #include "VideoBackends/OGL/GLInterface/GLX.h"
 #endif
feilen commented 9 years ago

Okay, I've got a working, totally legitimate OSX install to play with now. I'm working on getting support up and running right now. Unfortunately I don't actually have functioning 3d acceleration, but it's working well enough to sort out compilation bugs, but I might need your help in testing it once I've got that sorted out.

pizthewiz commented 9 years ago

Great! Just point me at a branch and let me know what you'd like some eyes on.

feilen commented 9 years ago

Guess the problem is more complicated than I thought. I'll have to get back to you.

I'm thinking a possible (well, probable) source of issues is where when porting I'd change something windows-specific to something like:

#ifdef _WIN32
 // windows stuff
#else
 // linux stuff, sometimes using glx.h
#endif

I'll go over the differences between this and the dolphin-core and find anything I can like that, see what needs changing there.