Gamua / Sparrow-Framework

The Open Source Game Engine for iOS
http://www.sparrow-framework.org
Other
294 stars 83 forks source link

Fix for storing shader uniform and attrib location #10

Closed mnem closed 11 years ago

mnem commented 11 years ago

Currently, SPProgram uses the uniform name index as the program location for the uniform. While this works (through coincidence) on iOS 5 and 6, it breaks for iOS 7 preview 2, causing the call to glUniformMatrix4fv in SPBaseEffect.m:97 to fail with a GL_INVALID_OPERATION error due to the wrong location being used.

The fix is to use glGetUniformLocation and glGetAttribLocation to fetch the correct locations for the inputs from the input name.

The fix was tested with a trivial program showing a textured sprite and untextured quad which now works on both iOS 6.1 and iOS 7 DP2 (unfortunately I don't have any iOS 5 devices to hand). Unit tests also pass of course.

PrimaryFeather commented 11 years ago

OMG, you're right! Thanks a lot for that -- I looked over this code several times after iOS 7 beta was released, but always overlooked it. I thought it was a bug in iOS 7, and was about to open up an issue at Apple ... -- stupid me! You saved me a lot of time, thanks! :-)

mnem commented 11 years ago

Sometimes bugs just need a new set of eyes. I always find that out about 5 seconds after I've asked someone to help with something and they point out an enormous flaw in my code that my mind was suppressing :)