Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL ES 2 context creation is broken on Android #472

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

OpenGL ES 2 context creation is broken on Android #472

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.0
Reported for operating system, platform: Android (All), ARM

Comments on the original bug report:

On 2011-08-26 03:49:05 +0000, Tim Angus wrote:

Created attachment 683
Support for OpenGL ES 2 on Android

There are a couple of things missing from SDL_Activity.java that are necessary to support OpenGL ES 2 context creation. The contextAttrs part is from Forest Hale via the mailing list. He says:

"On an OpenGL ES 2 capable device, it is not enough to pick a config that supports ES2, it is necessary to specify an EGL_CONTEXT_CLIENT_VERSION of 2 when one is wanted... I have revised the eglCreateContext call as shown below in my local copy.

I also think the eglChooseConfig is busted, the first config reported on my device has EGL_DEPTH_SIZE 0 which makes it rather useless for a 3D game, I uncommented the request for EGL_DEPTH_SIZE 16 in my local copy for this purpose, the alternative would be to request a large number of configs (I got over 20 unique ones in testing... so a larger number is required) and picking the "best matching" one.

This is just a bland snippet of revised code for android-project/src/org/libsdl/app/SDLActivity.java - sorry for any inconvenience with it not being a directly applyable patch.

         int EGL_CONTEXT_CLIENT_VERSION=0x3098;
         int contextAttrs[] = new int[]
         {
             EGL_CONTEXT_CLIENT_VERSION, majorVersion,
             EGL10.EGL_NONE
         };
         EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, contextAttrs);"

I've also changed the constant passed to eglWaitNative as it was causing console spam on every buffer flip. The man page states:

"Parameters

engine

Specifies a particular marking engine to be waited on. Must be EGL_EGL_CORE_NATIVE_ENGINE."

So I've used this constant instead and the console spam goes away.

On 2011-08-26 05:16:14 +0000, Tim Angus wrote:

Created attachment 685
Support for OpenGL ES 2 on Android

On 2011-08-26 05:54:33 +0000, Gabriel Jacobo wrote:

If I may add a report on this, on a Asus Transformer device (Android 3.2, Nvidia Tegra), I see the OpenGL ES 2 process fail at GLES2_CreateRenderer.
Specifically, it fails when it queries

glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats);
glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler);

and

glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats);

(By the way, nFormats and hasCompiler should be initialized to 0 and false, in my case I found it hard to figure out because nFormats had for some reason a value of 3, so the code kept going assuming the call was successfull).

The gl error in all those calls is GL_INVALID_ENUM

On 2011-10-13 21:18:21 +0000, Ryan C. Gordon wrote:

Tim's patch is now hg changeset 75c796a375e1.

What's the fix for Gabriel's GL_INVALID_ENUM? Are we supposed to be checking for an extension before those queries?

--ryan.

On 2011-10-14 04:03:55 +0000, Gabriel Jacobo wrote:

This is fixed AFAICT, I'm not sure if it got fixed because of the proper context creation from this patch or because of the GetProcAddress implementation from # 1290, but the thing is it works so let's not look at it too closely for fear of breaking it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant