The goal of this bug is to modify the current OpenGL implementation of GraphicsContext3D so that it becomes usable by both Mac and Gtk port and perhaps any other port that would decide to use it in future.
Discussion has already been started on the mailing list.
Add Zhenyao Mo and Kenneth Russell to the CC list, as requested.
Created attachment 83783 [details]
Modifying the Extensions3DOpenGL class
As discussed with Kenneth on IRC, Gtk port cannot foresee what extensions functions the drivers will be able to offer. By using phrase 'extensions functions' I mean _every_ function that can be extensible (for instance glIsProgramARB, glUniform1fARB, glBlitFramebufferEXT etc). Therefor Gtk port is planning to go through a list of these functions and try loading every function with possible extension suffix through glXGetProcAddress.
Because of that it is necessary to move calls to OpenGL extensions functions out of the GraphicsContext3D class in order to make it usable to the Gtk port as well.
This patch recommends adding further extensions functions to the Extensions3DOpenGL class that would then be implemented separately in the Gtk and Mac port. The patch offers a bare file with basic implementation for the latter, but I'm not sure whether this would be a .mm or a .cpp file (not familiar with the Mac build system). Changes to the GraphicsContext3D class are not included, but it would basically come down to replacing calls to any extensions function with m_extensions->function().
Seeing this just now, the recently added vertex array extensions functions should probably also be branched out into separate files as implementing them on the Gtk port would probably need a different approach.
This patch is of illustrative nature and would welcome opinions on this approach, so no ChangeLog entries were generated and a license header is also missing from the new file.
I don't think I understand. Why do you add all the core GL functions to Extension3DOpenGL? They are already in GraphicsContext3D. Extension3D is for extensions only.
(In reply to comment #3)
> I don't think I understand. Why do you add all the core GL functions to Extension3DOpenGL? They are already in GraphicsContext3D. Extension3D is for extensions only.
These aren't all of the core OpenGL functions, but those which need to be looked up as extensions on some platforms.
The general approach seems OK to me. You'd want to comment the large block of functions indicating the reason they're there. You'll also need to make sure it builds and works on both Mac and Gtk.
Created attachment 85933 [details]
This patch includes the following:
- 91 extensible functions are added to the Extensions3DOpenGL class. These functions are meant to be implemented for each port that uses OpenGL implementation of GraphicsContext3D separately. A comment explaining the situation is added at the top of these functions.
- An implementation is included for the Mac port, located in platform/graphics/mac/Extensions3DOpenGLMac.cpp. The implementation is basically using the same OpenGL functions as they were used in GraphicsContext3DOpenGL.cpp. I'd like some input on whether this should be a .mm file or a .cpp file (as it is currently - I'm not familiar with the Mac build). I'd also be grateful if someone with access to a Mac build could add this file (Extensions3DOpenGLMac.cpp) to the build.
- Call to every OpenGL function in GraphicsContext3DOpenGL.cpp that could be extensible is replaced with an appropriate call to a Extensions3DOpenGL class function. This is the part of the patch that really introduces shareable GC3D. The same is done in GraphicsContext3DMac.cpp.
- Extensions3DOpenGL::blitFramebuffer and Extensions3DOpenGL::renderbufferStorageMultisample are moved to Extensions3DOpenGLMac.cpp and are still executing the same OpenGL calls.
With these modifications the Gtk port (and any other port that would want to use OpenGL GC3D) simply needs to implement functions of Extensions3DOpenGL class in a way that calls those extensions functions that are actually available.
A lot has changed since this was filed. Taking the liberty to close this. Please file a bug with new description should some parts of this still apply.