Rendering Glitch on Mac OSX El Capitan with OpenGL

不打扰是莪最后的温柔 提交于 2019-12-01 06:42:12

问题


I created a tennis game for OSX using SDL 1.2 + OpenGL 1.1 .

Everything was ok till El Capitan. Now, a few textures aren't displayed correctly.

The court white lines are now black ; the player textures are all bad ; the energy bars on the left are all black:

The white lines on the icons aren't normal. The rainbow texture on the highlighted icon isn't either:

How the game should normally looks:

So the wrong textures are:

  • the players : they are re-created in-game using different textures, using RGBA
  • the white lines (now black) : normal RGBA texture
  • the energy bar (on the left) : normal RGBA texture
  • some other GUI elements, but not all : mostly normal RGBA textures

Moreover, it's only the AppStore version of the game that gets these glitches. The version I distribute from my website seems to be glitch free ( => http://www.managames.com/predownload_en.php?f=TennisElbowMac_sto.zip )

I'm totally puzzled by what's going on. I know El Capitan just brought a big change in the way the OS renders things, but I have no idea where to look and even less what to fix.

It seems it only touches RGBA textures, but not all of them as most GUI elements are still correctly displayed.

So thanks in advance for any tips you may have !


回答1:


I am having the same issue with my graphics in software. I am using SDL 1.2 and SDL_image 1.2.12. I tried to change the format of images that I am loading with SDL_image as SDL_Surface * const surface = IMG_Load(filename);

but nothing worked. At the end, as a quick fix, I changed my graphics to BMP (disaster) and load them with pure SDL's function:

SDL_Surface * const surface = SDL_LoadBMP(filename); 

After that I don't have the glitches anymore. This is not final solution especially if you have lot of graphics.




回答2:


Thanks to the help of Sidney Markowitz from this thread => https://lists.gnu.org/archive/html/enigma-devel/2015-10/msg00001.html , I figured a solution : replacing SDL_Image 1.2.12 version by 1.2.10 version.

If I got this right, the catch is that 1.2.10 comes with old universal code which is not allowed on the AppStore, so submitting an App with this version would likely end in a rejection. So I'm going to try to recompile it with only x86 code, that should likely do the trick.

EDIT:

Instead of recompiling, I just used Lipo ( http://www.manpages.info/macosx/lipo.1.html ), like this :

lipo -remove ppc -output ~/Documents/SDL_image /Library/Frameworks/SDL_image.framework/Versions/A/SDL_image

And then moved back "~/Documents/SDL_image" to "/Library/Frameworks/SDL_image.framework/Versions/A/" . And finally I edited its info.plist to fix the Bundle ID (needs 2 dots in it) so publishing on the AppStore could work.

Thanks again to Sidney Markowitz for the Lipo hint ! :-)

EDIT2:

New version has been rejected by Apple, because SDL_image 1.2.10 uses a deprecated CGDataProviderCreate API. The code contains a "#ifdef" to use a newer replacement, so I'll have to recompile it instead of using Lipo, but I'm afraid this newer replacement is the actual source of the glitch on OSX El Capitan.

EDIT3:

Recompiling SDL_image 1.2.10 works, but not as it, I had to change the installation folder to @rpath and a few other parameters and then it was successfully accepted on the AppStore.




回答3:


For anyone else having problems with graphical glitches on OS X El Capitan and pygame, you can follow these instructions to downgrade to SDL from version 1.2.12 to 1.2.10, which seems to fix the issue (at least in several of the games I've tested so far):

All the following is from the command prompt:

  1. Backup the original ruby Formula (just in case):

    mv /usr/local/Library/Formula/sdl_image.rb /usr/local/Library/Formula/sdl_image_backup.rb

  2. This creates a new Formula using the sdl version 1.2.10 instead:

    brew create https://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.10.tar.gz

  3. It should open in a text editor automatically, if not open it with vim/emacs/nano/whatever you prefer and edit it to match most of what the original sdl_image.rb (now sdl_image_backup.rb) says, but skip the "bottle do" part and the "test" part.

  4. Set environment variable (not sure this is required but worked for me):

    export SDL_CONFIG=/usr/local/bin/sdl-config

  5. Unlink the old 1.2.12 install:

    brew unlink sdl_image

  6. Now reinstall, but brew will use our new Formula for 1.2.10:

    brew install sdl_image




回答4:


saltycraig's answer worked for me, but I had to figure a few things out on my own that I thought I would include here so people don't have to struggle to figure it out.

First, when you're in step 3 and changing your new sdl_image.rb to match the backup, make sure to keep the url from the new one, containing this address: "https://www.libsdl.org/projects/SDL_image/release/SDL_image-1.2.10.tar.gz". That may seem obvious, but I didn't figure it out until my 2nd or 3rd time looking it over.

Second, even after unlinking sdl_image and installing 1.2.10, you may need to delete 1.2.12. For me it was in usr/local/Cellar/sdl_image because I brewed python to get around El Capitan's new SIP preventing me from installing pygame.



来源:https://stackoverflow.com/questions/33115482/rendering-glitch-on-mac-osx-el-capitan-with-opengl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!