oakmound / oak

A pure Go game engine
Apache License 2.0
1.52k stars 84 forks source link

Hotfix: OSX ARM colors #200

Closed 200sc closed 2 years ago

200sc commented 2 years ago

On my three OSX (one Intel, two ARM) machines, I've consistently observed that the Intel machine, no matter what we do within the OS driver, expects the pixel data drawn to windows to be RGBA. On ARM it expects BGRA.

I have been unable to find references to others experiencing this. I have also been unable to find anything within metal, glfw, or cocoa that would programmatically expose that the OS is doing this to us. So:

This PR changes mtldriver to use image.RGBA if on Intel, and a locally defined copy of image.RGBA with R and B flipped, BGRA when on ARM.

Re: help wanted:

Do you have a mac? Regardless of whether it is ARM or Intel, please try this branch out to confirm the above suspicion. Run this command from the repository's root: cd examples/top-down-shooter-tutorial/6-performance && go run performance.go

And you should see colors like this:

Screen Shot 2022-04-03 at 1 07 19 PM
codecov-commenter commented 2 years ago

Codecov Report

Merging #200 (679b2d0) into master (135b087) will decrease coverage by 0.18%. The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #200      +/-   ##
==========================================
- Coverage   92.39%   92.20%   -0.19%     
==========================================
  Files         141      141              
  Lines        6456     6456              
==========================================
- Hits         5965     5953      -12     
- Misses        430      440      +10     
- Partials       61       63       +2     
Impacted Files Coverage Δ
drawLoop.go 39.75% <0.00%> (-7.23%) :arrow_down:
event/handler.go 96.66% <0.00%> (-3.34%) :arrow_down:
collision/rtree.go 97.90% <0.00%> (-1.40%) :arrow_down:

:mega: Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

nfuden commented 2 years ago

Have intel mac. Between master and new branch no change in coloration per expectations. Do not have arm cannot confirm behavior there.