openFrameworks
openFrameworks copied to clipboard
issue with simple line drawing
I’m on macOS 10.12.6 with Xcode Version 9.2 beta (9C32c) with MBP Retina display running this simple code
ofBackground(0);
int _h = mouseX;
ofSetColor(255);
for(int i=0; i<1000; i++){
ofDrawLine(i, _h,i, _h+20);
}
produces this image where lines should have been drawn one beside the next but for some reason some are on top of each other. I have seen this in previous versions too.

I had a similar issue a few months ago on a MacBook pro (15inch with retina display from mid 2015), on macOS Sierra 10.12.6. I tried the code on Xcode Version 9.2 (9C40b), Xcode Version 8.0 (8A218a) and Qt Creator as well as different versions of openFrameworks (of_v0.9.8_osx, of_v20170714_osx, 0.10.0) I just run it again trying the new of0.10.0_RC4 on Xcode Version 9.2 (9C40b) with the same results.
This was the code to create a gradient by drawing vertical lines:
ofBackground(0);
for (int i = 0; i < ofGetWidth(); i++)
{
int grey = ofWrap(i, 0, 255);
ofSetColor(grey);
ofDrawLine(i, 0, i, 255);
}
And this was the output
I was able to “fake” the desired output by setting the lineWidth to 2.
ofBackground(0);
for (int i = 0; i < ofGetWidth(); i++)
{
int grey = ofWrap(i, 0, 255);
ofSetColor(grey);
ofSetLineWidth(2);
ofDrawLine(i, 0, i, 255);
}
This is the result:
However, when drawing horizontal lines the issue did not occur, although the gradient did not go all the way to white (which it did when setting the line width to 2 again):
ofBackground(0);
for (int i = 0; i < ofGetWidth(); i++)
{
int grey = ofWrap(i, 0, 255);
ofSetColor(grey);
ofDrawLine(0, i, 255, i);
}

To add another data point:
- oF Master (RC4)
- macOS 10.13.4
- MacBook Pro (15-inch, 2017) (retina)
- Xcode Version 9.2 (9C40b)
ofApp::draw() {
ofBackground(0);
for (int i = 0; i < ofGetWidth(); i++)
{
int grey = ofWrap(i, 0, 255);
ofSetColor(grey);
ofDrawLine(i, 0, i, 255);
}
}

To add another data point:
oF Master (RC4) macOS 10.13.4 MacBook Pro (15-inch, 2017) (retina) QTCreator 4.5.1

I also tried to open the same app in low res mode with the same results.
Also, it doesn't seem to matter what GL version is used main.cpp
:
#include "ofApp.h"
int main()
{
ofGLWindowSettings settings;
settings.setSize(1024, 768);
// settings.setGLVersion(2, 1);
// settings.setGLVersion(3, 2);
// settings.setGLVersion(4, 1);
settings.windowMode = OF_WINDOW;
auto window = ofCreateWindow(settings);
auto app = std::make_shared<ofApp>();
ofRunApp(window, app);
return ofRunMainLoop();
}
Have you tried disabling antialiasing? in main set window settings numSamples to 0 or in setup call ofDisableAntialiasing()
This is with 0.9.8 but there are differences in Release/Debug so may offer a clue
Release:
Debug:
@arturoc ofDisableSmoothing()
has no effect.
Playing with numSamples
also doesn't seem to have an effect.
int main()
{
ofGLFWWindowSettings settings;
settings.setSize(1024, 768);
// settings.setGLVersion(4, 1);
settings.numSamples = 4;
settings.windowMode = OF_WINDOW;
auto window = ofCreateWindow(settings);
auto app = std::make_shared<ofApp>();
ofRunApp(window, app);
return ofRunMainLoop();
}
Could this be a GL driver bug on macOS?
no, ofDisableSmoothing is a different thing and is disabled by default, i was saying ofDisableAntialiasing() but numSamples=0 should have the same effect
@bakercp looks like a GL driver issue to me. It could be that with Mac OS Sierra and onwards OpenGL calls are routed/emulated through Metal, and that line drawing + overdraw trip up their driver. A way to check this hypothesis would be to test the code on a Mac with older OS...
For comparison, here's how linux draws the above:
I'm on Sierra
And I dont see the artifacts described.
Im using xcode 8.3.2 and OF's current github master
I used the following code
void ofApp::draw(){
ofBackground(0);
for (int i = 0; i < ofGetWidth(); i++)
{
int grey = ofWrap(i, 0, 255);
ofSetColor(grey);
ofDrawLine(i, 0, i, 255);
}
}
I suspect this has something to do with the macOS AMD graphics card driver.
I think it is amd related too no artifacts on M1 here
I suppose this issue won't be addressed because it seems to be OS related. should we close it?