Bug 51542 - [iOS] PixelFormat does not define BGRA
Summary: [iOS] PixelFormat does not define BGRA
Alias: None
Product: iOS
Classification: Xamarin
Component: OpenTK ()
Version: XI 10.4 (C9)
Hardware: Macintosh Mac OS
: Normal enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
Depends on:
Reported: 2017-01-15 02:12 UTC by bben.pub
Modified: 2017-02-28 16:47 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 51542 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description bben.pub 2017-01-15 02:12:09 UTC

In the OpenGL's glTexImage2D function, the pixel format can normally be GL_BGRA: https://developer.apple.com/reference/opengles/1617448-glteximage2d in the "format" parameter.

In Xamarin, it's mapped to an OpenTK.Graphics.ES20.PixelFormat enum, which does not define Bgra.

Is it possible to add this value, please?
Comment 1 Sebastien Pouliot 2017-01-16 22:02:35 UTC
Your link does not include any information about what Apple allows (or not) for the `format` parameter.

The usage of `GL_BGRA` seems to be valid for OpenGL but not for OpenGLES 2 (ES20) or even 3 (ES30) [1].

[1] https://www.khronos.org/opengles/sdk/docs/man3/html/glTexImage2D.xhtml
Comment 2 bben.pub 2017-01-17 04:54:35 UTC
Sorry, I forgot to put the actual OpenGL documentation :(
However, I was indeed looking at the full OpenGL and not OpenGL ES, so you're right.
But... this works:
GL.TexImage2D(All.Texture2D, 0, (int)All.Rgba, width, height, 0, All.BgraExt, All.UnsignedByte, pixels);

Because Apple added an OpenGL ES extension for that:
And there is a discussion here:

So, it seems that the actual format that could be added is "BGRA_EXT". I couldn't find any other extra format.

Please note that it's only a "format" (7th parameter) and not an "internalFormat" (3rd parameter), otherwise it causes an error.

I hope this helps,
Comment 3 Vincent Dondain [MSFT] 2017-02-24 23:25:45 UTC

Can you clarify this part:

"So, it seems that the actual format that could be added is "BGRA_EXT". I couldn't find any other extra format."

I'm not sure what's you're suggesting / expecting.

There is `OpenTK.Graphics.ES20.All.BgraExt` right, so what would we be missing?
Comment 4 bben.pub 2017-02-25 15:23:03 UTC
Yes, but it is not part of the OpenTK.Graphics.ES20.PixelFormat enumeration. So it cannot be used as an argument for the strongly typed version of OpenTK.Graphics.ES20.GL.TexImage2D. And the use of the weakly typed version is marked as obsolete.
Comment 5 Vincent Dondain [MSFT] 2017-02-28 16:47:10 UTC
Okay now I understand your request, sorry for the delay (;

Indeed we could likely spice up these PixelFormat enums especially since the overloads that are not using it are obsolete.

@radek any comment on this?