Is there any way to set the OpenGL version?

588 views
Skip to first unread message

Pris Matic

unread,
Feb 27, 2016, 5:18:00 PM2/27/16
to skia-discuss
I'm trying to use Skia to render with an existing OpenGL context. I followed SkiaSDLExample.cpp in the /example source directory to set everything up and it seems to be working. However, I can't find any API to set the version of OpenGL to use. Typically when creating an OpenGL context you specify version and profile. Skia seems to query the OpenGL version string directly (in GrGLAssembleInterface) and sets up OpenGL based on that.

So if I request an OpenGL 2.1 context but my video card supports OpenGL 4.5, Skia assumes capabilities from the driver version string (which will show OpenGL 4.5). Is there a way to set the desired OpenGL version manually? 


Preet

Brian Salomon

unread,
Feb 27, 2016, 8:04:53 PM2/27/16
to skia-discuss
Hi,

If you have your OpenGL 2.1 context bound to the current thread and call GrContext::Create(kOpenGL_GrBackend, 0) Skia should use the existing context which should have a 2.1 GL_VERSION string. Out of curiosity, why limit yourself to the 2.1 feature set?

Brian

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To post to this group, send email to skia-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/skia-discuss.
For more options, visit https://groups.google.com/d/optout.

Pris Matic

unread,
Feb 28, 2016, 2:47:48 AM2/28/16
to skia-discuss
On Saturday, February 27, 2016 at 8:04:53 PM UTC-5, Brian Salomon wrote:
Hi,

If you have your OpenGL 2.1 context bound to the current thread and call GrContext::Create(kOpenGL_GrBackend, 0) Skia should use the existing context which should have a 2.1 GL_VERSION string.

On my system, even though I have a 2.1 context 'requested', the version string glGetString(GL_VERSION) gives me is specifically "4.5.0 NVIDIA 355.11". The GL docs say "The client and server may support different versions or extensions. glGetString always returns a compatible version number or list of extensions. The release number always describes the server."

I don't know if that means that I actually have a 4.5 compatibility context or 2.1 (I'm using SDL and querying that tells me the context is 2.1). Skia seems to work fine with the 4.5 path regardless (I see its using glsl 330 shaders)... but maybe thats because of a lenient driver.

Out of curiosity, why limit yourself to the 2.1 feature set?

I'm targeting 2.1/ES2 to try and maximize compatibility. The rest of my application (which also uses OpenGL independently of Skia) uses only GL2 as well. 

Brian Salomon

unread,
Feb 28, 2016, 11:07:53 AM2/28/16
to skia-discuss
I see. So the context created through SDL is actually 4.5. I think there are a couple options:

1) Modify SDL code to create a ES2 context. The GLX and WGL windowing layers support this, see WGL_EXT_create_context_es2_profile and GLX_EXT_create_context_es2_profile

2) Create your own GrGLInterface and pass it to GrContext::Create()'s second param. It should be possible to write a function like GrGLCreateNativeInterface that provides the platform GL functions for most functions but puts its own shim in for glGetString which will filter the version and extension strings.

Brian

--
Reply all
Reply to author
Forward
0 new messages