openframeworks / openframeworks/openFrameworks
Difficulty drawing pixel-accurate images in iOS 10.1 GLES2
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.4k
- Forks
- 2.6k
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 9
Description
When I draw an image that's made up of alternating black and white pixels like this:
for(int y = 0; y < h; y++) {
for(int x = 0; x < w; x++) {
bool on = x % 2 == 0 && y % 2 == 0;
img.setColor(x, y, on ? ofColor::white : ofColor::black);
}
}
(Inverse of the pattern here.) Then I get moire patterns.

The above test is with ES2 and with 4-sample antialiasing enabled. Disabling antialiasing changes the pattern but does not remove the moire. ES1 does not show a moire pattern regardless of whether antialiasing is true or false.
I checked out the latest OF, pulled libs, and created a project with the project generator (copied from the 0.9.8-ios release). I'm running iOS 10.1 and XCode 8.1.
If I add the line ofSetupScreenOrtho(ofGetWidth(), ofGetHeight(), -1, +1); at the top of draw() then everything is ok on the real hardware. In the simulator the pattern is still "blurry" (instead of a 2x2 square being [255, 0, 0, 0] it's [149, 43, 43, 17]) but there is no moire. I tried checking if the difference between the hardware and the simulator is due to floating point accuracy, but I think it must be the graphics card. Because the matrices computed by ofSetupScreenOrtho() are exactly the same.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the alternating-pixel image on iOS 10.1 with GLES2, comparing 4-sample antialiasing, no antialiasing, ES1, and the simulator. The issue names no source files or tests; done would mean determining the cause and eliminating the moire without relying on ofSetupScreenOrtho().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, ios
- Domain
- computer-graphics, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100