To anti alias your lines the simplest solution would be to use hardware MSAA, which from the code snippet you have supplied seems to be already setup correctly through the use of the EGL_SAMPLES and EGL_SAMPLE_BUFFERS attributes.
I will look at the custom methods you provided of antialiasing as well.
Well, the quality of the lines remains the same as before when using the code I mentioned which used MSAA - no antialiasing applied at all. I want to understand possible reasons of why it is not applying.
I just tried to remove EGL_LEVEL attribute which results eglChooseConfig returning false.
Why is this happens when removing EGL_LEVEL ?
What is the correct set of attributes for hardware accelerated MSAA ?
That is very strange indeed, I have tested the MSAA myself and I can confirm that setting the attributes EGL_SAMPLES and EGL_SAMPLE_BUFFERS does result in smoothed lines and reduced aliasing. May I suggest you take a look at the OGLESHelloAPI example which can be found in our SDK:
Please edit the example with the above changes and let me know if you get a smoothed line. I have attached two screenshots to this post hopefully you can see the difference I get between MSAA and no MSAA.
I have just tried your changes but the line is still jagged, no antialising applied.
here’s the screenshot I made.
I have also noticed some strange behavour when running OGLESHelloAPI.exe file -
it runs successfully ether from visual studio or from the directory but closes (terminates) after 1 second of running just immideatly. I have no idea why is this happens as well.
the directory with executable contains libEGL and libGLESvs2 runtime libraries.
Your graphics card should support MSAA. Could you add the snippet of code (below) to the HelloAPI example after the function eglChooseConfig and print out the value, this will check to see if an MSAA buffer has actually been created, an output of 1 will indicate creation was successful and an output of 0 would indicate no MSAA buffer has been created.
No sorry if I was not clear could you check the value of msaaBuffers, the function itself returns a boolean, but the value we are interested in is the value it writes to msaaBuffers.
[scode lang="{language}"]EGLint msaaBuffers;
eglGetConfigAttrib(eglDisplay, eglConfig, EGL_SAMPLE_BUFFERS, &msaaBuffers);
if (msaaBuffers == 0)
{
MessageBox(0, _T(“msaa buffer has not been created”), ERROR_TITLE, MB_OK | MB_ICONEXCLAMATION);
return false;
}[/scode]
just tried the last corrected code.
and after execution of [scode lang="{language}"]eglGetConfigAttrib [/scode] function, the value of [scode lang="{language}"]msaaBuffers [/scode] is 1.
This is a long shot but could you try to run my executable (see attached) with DLL’s from our github (I can’t attach them here because they are too big), just to rule out corrupt libraries etc:
This really is strange, do you happen to have PVRVFrame installed, if so could you launch it and then launch the HelloApi example, then in VFrame go to the context tab, could you then scroll down the list of extensions for the OpenGL (Host) and look for: GL_ARB_ES2_compatibility & GL_ARB_ES3_compatibility. (see attachment)
At the moment I am not really sure what else to suggest, we seem to have exhausted all possibilities (that I can think of), it’s possible that it is a driver problem but I could not say for sure.
I have finally figured out the problem and solution.
From the NVIDIA Control Panel (if your video card is nvidia) in the Manage 3D settings section, the option for Antialiasing Mode should be set to Application Control" to allow user written applications enable hardware MSAA, otherwise any attempt (even if it is desktop OpenGL app with glfw, glew etc) will fail if that option is set to Override any application settings and from the driver side it will be changed thus no methods will work - but I think shader based antialiasing should work anyway !?
However, choosing the right setting from there still didn’t help for my app, but did help for the hello api example,
because when manually setting up the MSAA through EGL there something (I didn’t figure out what) was incorrect and incomplete compared to HelloApi source code, instead I just did [scode lang="{language}"]this->setAASamples(4);[/scode] and it set up properly antialiasing and now the lines are antialised !!!
I am glad you found the solution to your problem, I honestly did not think about Nvidia control panel settings overriding application settings - good spot!
If you have any more queries please don’t hesitate to ask.
Hi Shanun,
Because I saw this post, I wanted to ask you some questions about MSAA. Our platform is using the PowerVR® BXS 4-64 MC1 core GPU, and then we try to turn on hardware anti-aliasing during EGL inti. The following is my code diff,
However, once EGL_SAMPLE_BUFFERS, 1, EGL_SAMPLES, 4 are added, EGL will fail to initialize where eglsurface is created (eglCreatePixmapSurface) and return 0.