Previously I'm using OpenGL on Mac via glew 2.1.0 and JUCE5, but it can only access OpenGL 2.1 APIs. I can't believe that my Macbook Air (Intel Graphics) bought on 2018 can only provide this, and I'm tired to maintain two sets of API calls and shaders for 2.1 and 3.X separately. Then I tried to replace all #include <GL/glew.h> with #include <OpenGL/gl3.h>, then link with OpenGL framework directly. However, the program still failed to compile a #version 130 shader (it claims not supported).
Here I want to know that:
Does all recent Apple devices (after 2010) capable for OpenGL 3.0?
How to turn on OpenGL 3.0 support on MacOS?
Finally I found the way: I have to enable it on JUCE side. When JUCE's OpenGL context is created, I must explicitly set expected OpenGL version by setOpenGLVersionRequired( juce::OpenGLContext::openGL3_2 ) before using it.
IMPORTANT: this would still lead failure to a compile to #version 130 shader, as Apple would strictly deprecate all old features prior to specified API version. A simple workaround is to dynamically prepend a version declaration according to system type, as GLSL 1.3.0 features is mostly included by GLSL 1.5.0.
Related
I am trying to make use of some ES 3.1 features, and it's unclear if this is supported:
I notice that there is an OpenGL ES 3.1 header in the emscripten repository which defines some of the functions I'm looking for, and I can include them successfully in my project. However, they are not available when I try to link:
error: undefined symbol: glDispatchCompute (referenced by top-level compiled C/C++ code)
warning: _glDispatchCompute may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
The documentation says that OpenGL ES3 is supported if I specify -s FULL_ES3=1 (which I am doing).
Since there are headers for it, is this functionality available? If so, how do I enable support for it? (Does it require manually loading extensions or enabling experimental support in emscripten, for example?)
First thing to realize, is that decent Browsers currently implement only WebGL 1.0 (based on OpenGL ES 2.0) and WebGL 2.0 (based on OpenGL ES 3.0). So that Emscripten SDK may implement only features presented by WebGL 2.0 + extensions, and, unfortunately, Compute Shaders are not presented in any way in WebGL (and there are no more plans to add this functionality in future).
By the way, WebGL 2.0 support has been added to Safari 15 (iOS 15) only this (2021) year, so that even OpenGL ES 2.0 will not work on all devices.
I notice that there is an OpenGL ES 3.1 header in the emscripten
The extra <GLES3\gl3*.h> headers are there not because Emscripten implements all of them, but because this is a common way to distribute OpenGL ES 3.x headers that existing applications may rely on to conditionally load / use OpenGL ES 3.x functions at runtime, when they available.
The documentation says that OpenGL ES3 is supported if I specify -s FULL_ES3=1 (which I am doing).
I think that documentation is more or less clear about what FULL_ES3=1 adds:
To enable OpenGL ES 3.0 emulation, specify the emcc option -s FULL_ES3=1 when linking the final executable (.js/.html) of the project.
This adds emulation for mapping memory blocks to client side memory.
There is no word about OpenGL ES 3.1 here, nor a reason to expect a wonder from Emscripten, as I can barely imagine a reasonable hardware-accelerated way to emulate things like Compute Shaders on top of OpenGL ES 3.0. And software emulation would be certainly of no use for most applications.
WebGPU 1.0 that promised to appear mid '2022, is more capable than WebGL 2.0. So that WebGPU developers already see that at one time native WebGL 2.0 implementation in the Browsers could be replaced by a WebAssembly module implementing this legacy API on top of WebGPU - but in some very distant future. The same could also bring OpenGL ES 3.1/3.2 features to Emscripten SDK - at least theoretically, if somebody will be still interested to work on this.
It's quite a few years now that I develop and maintain an OpenGL app on macOS. Even on Catalina it runs beautifully and fast. Now I need to add a particles feature and use glDrawElementsInstancedARB. The extensions GL_ARB_draw_instanced and GL_ARB_instanced_arrays are present.
As I have read on the web, this command has to be used together with a GLSL shader, so I tried to develop a GLSL shader too. The problem: the shader won't compile. I get an error on the first line
layout (location=0) in vec3 position;
also, the max version allowed is
#version 130
while the GLView app (freely available on the MAS) tells me
CORE: OpenGL version 4.1 ATI-3.10.18
COMPATIBILITY: OpenGL version 2.1 ATI-3.10.18
and glGetString(GL_SHADING_LANGUAGE_VERSION) returns
GLSL Version: 1.20
I know that Apple has just deprecated OpenGL.
Anyway, do you think is a way to compile my shader?
Should I need to install something extra? If so, should my users install something extra too?
I decided to use GLEW for handling extensions instead of requesting core profile and having to migrate my code.
I would like to add support for FBO's through the EXT profile as a first step.
The problem is gcc will not link my code (OSX 10.10), it does not recognize any gl*EXT() functions. For instance, glBindFrameBufferEXT()
flags as undefined symbol. (glBindFrameBuffer() was also
unrecognized...)
I link against GLEW and have tried using GLEXT or GLFW with compatibility profile, but nothing works! Am I missing a library? How do I tell gcc to use the right GL profile? Am I obliged to migrate to core profile?
In MacOS X GLEW is not doing a lot, because there are not a lot of OpenGL extensions on MacOS X and due to the way OpenGL is integrated in MacOS X all functions of the OpenGL version supported by the available framework are immediately available
… or not, if you're using an extension function that's not supported by MacOS X's OpenGL implementation.
MacOS X is the weird duckling in the OpenGL family: OpenGL is used at a very low level in the OS's core graphics routines, to OpenGL is very well supported by the OS. But it's built so deep into the OS that it hardly can be updated without updating the whole OS.
Solution: Don't use that extension. FBOs have been introduced with OpenGL-3.3 so you've to create a 3.3 core profile context and can use the functions (without the …EXT) directly.
I am trying to program OpenGL 3 in C on my Macbook Pro.
My graphics card is NVIDIA GeForce 320M 256 MB, but I have OpenGL 2.1 According to wikipedia, I should be able to use OpenGL 3.3:
However, when I run glxinfo | grep -i opengl, I get OpenGL version string: 2.1 NVIDIA-8.24.16 310.90.9.05f01.
How do I go about upgrading it? I am running Mavericks.
Technically, you cannot get a (windowed) OpenGL 3.2 context programming purely in C on OS X.
You have to use part of Cocoa (an Objective-C framework) called NSOpenGL; AGL (deprecated C-based API) as well as the really old X server implementation (XQuartz) are perpetually limited to OpenGL 2.1.
Apple's own implementation of GLUT wraps NSOpenGL (FreeGLUT does not), and so do GLFW, SDL, etc. They have small portions that are written in Objective-C to interface with NSOpenGL and this allows them to create window-based OpenGL 3.2+ render contexts even in C software.
Now, the problem here is actually that glxinfo uses XQuartz, which does not support OpenGL 3.2+. I would suggest you use the OpenGL Extension Viewer on the Mac App store if you want detailed info about your OpenGL capabilities.
Since you're just starting out with OpenGL development on OS X, I would also suggest you have a look here for a quick overview of the various APIs.
You cannot upgrade your graphics drivers since they are provided by Apple. But your system should support OpenGL 3.3 ( https://developer.apple.com/opengl/capabilities/ ). When creating a OpenGL context you must request a CoreProfile mode. If you are using GLUT this can be done this way:
GLUT on OS X with OpenGL 3.2 Core Profile
I'm trying to learn OpenGL and the material is using #version 330 in shaders. I can compile it successfully, but when I try to run it, it complains Version 330 is not supported.
In my source code, I use free glut and OpenGL framework in Xcode. If I also include these two lines of code
glutInitContextVersion(3,1);
glutInitContextFlags(GLUT_CORE_PROFILE);
it cannot be compiled.
My mac is MacBook Pro Mid 2012. It should support OpenGL4.1 according to apply.
So how can I compile version 330 shaders?
OS X requires that you request a 3.2 core profile in order to receive a 3.3 or later context. This is because 3.2 finally removed the functionally that was deprecated in 3.0.
So if you want to use a #version 330 shader then your code should look like this:
glutInitContextVersion(3,2);
glutInitContextFlags(GLUT_CORE_PROFILE);
EDIT Apparently X11 doesn't support OpenGL higher than 2.1 on OS X. As such, I suggest you switch to GLFW.