Hi guys, about the problem of jagged basic primitive triangles

Hi guys, I draw a simple triangle, but I found that the anti-aliasing effect was not obvious when MSAA was turned on

Here is my draw triangle code

	ofVbo vbo;
	ofShader shader;
	std::vector<glm::vec3> vertex;
	vertex.push_back(glm::vec3(-0.1f, -0.1f, 0.0f));
	vertex.push_back(glm::vec3(0.1f, -0.1f, 0.0f));
	vertex.push_back(glm::vec3(0.0f, 1.0f, 0.0f));
	auto indices = std::vector<ofIndexType>(3);
	indices[0] = 0; indices[1] = 1; indices[2] = 2;
	vbo.setVertexData(vertex.data(), vertex.size(), GL_STATIC_DRAW);
	vbo.setIndexData(indices.data(), indices.size(), GL_STATIC_DRAW);

here is my create windows code

	ofGLFWWindowSettings settings;
	settings.setGLVersion(3, 3);
	settings.numSamples = 0;
	settings.setSize(900,900);
	ofCreateWindow(settings);

when setting
settings.numSamples = 4;

when setting
settings.numSamples = 0;

Why does multisampling still look flawed and the edges are jagged? How do you set it to make the triangle look smooth? Thanks

Hello,
I’m not sure I understand your problem but I post because you’ve got no answer.
settings.numSamples = 4 enable the multisampling, isn’t it ? That’s why your first triangle is good.
settings.numSamples = 0 disable the multisampling.

Thank you very much for your reply. What I mean is that the multi-sampling is opened in time, and there are still some jagged edges of the triangle. Is there any way to completely eliminate the jagged edges

Hi,

I think that will be as good as it gets with that drawing approach.
You might find rendering to a higher resolution ofFbo with numSamples = 4 and then drawing the fbo at a lower resolution might look better.

For what it is worth this is what I get with this code ( based on emptyExample with no changes in main.cpp ):

//--------------------------------------------------------------
void ofApp::draw(){
    ofBackground(0);
    ofTranslate(400, 600, 0);
    ofDrawTriangle(glm::vec3(-0.3f, 0.1f, 0.0f)*500.0, glm::vec3(0.3f, 0.1f, 0.0f)*500.0, glm::vec3(0.0f, -1.0f, 0.0f)*500.0);
}

All the best,
Theo